mfatemipour commented on issue #43252:
URL: https://github.com/apache/airflow/issues/43252#issuecomment-2505489554
Yeah, first of all, following code to check that a url is external is buggy:
```
const isExternal = (url: string | null) =>
url && /^(?:[a-z]+:)?\/\//.test(url);
```
This regex will accept a url starting with "//"
so first let's fix this (removing `?`):
```
const isExternal = (url: string | null) =>
url && /^(?:[a-z]+:)\/\//.test(url);
```
And for the isSantised method let's reuse this isExternal
to check that if url is external or internal (for internal check, starts
with a single `/` character)
```
const isSanitised = (url: string | null) => {
if (!url) {
return true;
}
return isExternal(url) || /^\/[^\/]/.test(url);
};
```
I cannot test it, I don't have a ready airflow dev environment on my
business machine, otherwise I would be appreciated to contribute.
--
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]