-
-
Notifications
You must be signed in to change notification settings - Fork 728
Implement URL normalization in code snippet handler #3409
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
Conversation
5eb7732
to
1c28dfc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, should we add & pin yarl as we are now explicitly using it? (I know it's present as a dependency of aiohttp but we should probably pin it ourselves).
Add URL normalization checks using yarl in code snippets.
1c28dfc
to
5aa0398
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is some potential for false positives here as there is nothing inherently wrong with an unnormalised URL. I don't think it's really an issue because I can only think of examples that you would have to craft on purpose, e.g. if you percentage encode part of the URL (e.g. if you had a file called #
or ?
:D) and decide to do it in lowercase %3f
, yarl will normalise to uppercase %3F
.
This is definitely better than allowing arbitrary requests to be made, and I can't really think of a neater approach.
Ideally we would probably have a helper we can use everywhere when substituting stuff into URLs (possibly a nice use case for PEP 750...). Even this ends up being a bit difficult to do perfectly though, as some URL parameters need to be more permissive than others, and it's not always clear when to quote vs when to just reject something.
Let me check that before you merge |
Never mind I just misread the code, I see no issues with this |
Add URL normalization checks using yarl in code snippets.
closes #3315
Thanks to @decorator-factory for the idea.
tested on @pydis-bot and deployed on @monty-python-bot