Skip to content

Commit

Permalink
Adding url sanitisation for extra links (#41665) (#41680)
Browse files Browse the repository at this point in the history
(cherry picked from commit 6c463b3)
  • Loading branch information
amoghrajesh authored and utkarsharma2 committed Sep 2, 2024
1 parent 400dddc commit ceb6051
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion airflow/www/static/js/dag/details/taskInstance/ExtraLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ const ExtraLinks = ({
const isExternal = (url: string | null) =>
url && /^(?:[a-z]+:)?\/\//.test(url);

const isSanitised = (url: string | null) => {
if (!url) {
return true;
}
const urlRegex = /^(https?:)/i;
return urlRegex.test(url);
};

return (
<Box my={3}>
<Text as="strong">Extra Links</Text>
Expand All @@ -63,7 +71,7 @@ const ExtraLinks = ({
as={Link}
colorScheme="blue"
href={url}
isDisabled={!url}
isDisabled={!isSanitised(url)}
target={isExternal(url) ? "_blank" : undefined}
mr={2}
>
Expand Down

0 comments on commit ceb6051

Please sign in to comment.