-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: return a 400 for malformed URIs #64
Conversation
403e4eb
to
4a183bb
Compare
Quick question: Why does it crash there and not here? https://github.com/nodejs/release-cloudflare-worker/blob/main/src/handlers/get.ts#L29 |
Honestly I don't know, my best guess is that calling |
Could also be lazy construction/validation |
I'm not sure you're supposed to call |
Right, I think it is indeed unnecessary as URL already does the sanitizations that are needed on the Off-topic: @flakey5 I believe release-cloudflare-worker/src/util.ts Lines 53 to 61 in b854489
Like I didn'te ven realise |
The call to
Yeah that sounds like a good idea as well |
Yes, but why do we need it? There are no legitimate URLs that need percent encoding in the pathname. |
Another approach could be to call |
That sounds the best approach here, and to catch the broken URL directly when calling `new UR. (inside the parseURL) (with try/catch) so we return undefined -> BAD_REQUEST directly from there |
If we don't need to validate the uri I think we can just go without it, if it becomes a need later on (e.g. file names with spaces) we can add it back |
bd503e3
to
80d53d6
Compare
80d53d6
to
adbe905
Compare
I think the idea was to validate the url within But I guess we can also simply do it like this for now, and be reactive if errors arise. |
See https://nodejs-org.sentry.io/issues/4622681006/events/3a4e26a6669c46ffb84f20369e90ac8c/