Skip to content

Commit 52215d5

Browse files
committed
updating regex to validate trigger url
1 parent 772568b commit 52215d5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

client/src/pages/TriggerWorkflowForm/TriggerWorkflowForm.jsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ const TriggerWorkflowForm = () => {
1717
const type = searchParams.get('type');
1818
const triggerUrl = searchParams.get('triggerUrl');
1919

20-
if (triggerUrl !== null) {
20+
const triggerUrlPattern = /^https:\/\/(?!.*javascript)[^()]+$/i;
21+
22+
function isValidTriggerUrl(url) {
23+
try {
24+
// Check if it's a valid URL and matches the pattern
25+
return triggerUrlPattern.test(decodeURIComponent(url)) && new URL(url);
26+
} catch {
27+
return false;
28+
}
29+
}
30+
31+
if (triggerUrl !== null && isValidTriggerUrl(triggerUrl)) {
2132
return (
2233
<div className="page-box">
2334
<Header />

0 commit comments

Comments
 (0)