utkarsharma2 commented on code in PR #41995:
URL: https://github.com/apache/airflow/pull/41995#discussion_r1744019178


##########
airflow/www/static/js/dag/details/taskInstance/ExtraLinks.tsx:
##########
@@ -57,8 +57,27 @@ const ExtraLinks = ({
     if (!url) {
       return true;
     }
-    const urlRegex = /^(https?:)/i;
-    return urlRegex.test(url);
+    try {
+      const path = new URL(url);
+      // The URL creation will succeed for
+      // 1. Absolute URL
+      // 2. URL with javascript:()
+      // URL(url) will fail for relative paths.
+      // eslint-disable-next-line
+      if (path.protocol === "javascript:") {
+        return false; // javascript:() is not allowed
+      }
+      if (path.protocol === "http:" || path.protocol === "https:") {
+        return true; // Absolute URL are allowed
+      }
+    } catch (e: any) {
+      // Relative URL are handled here
+      const path = new URL(url, "http://localhost";);
+      if (path.protocol === "http:") {

Review Comment:
   Correct, updated the code, accordingly. PTAL.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to