validate the scheme against the RFC 3986 grammar - #1813
Open
Samin061 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What do these changes do?
URL.build(scheme=...)andURL.with_scheme()write the caller-supplied scheme into the URL without checking it against the RFC 3986 scheme grammar, and a scheme is never escaped, so a delimiter in it restructures the rendered URL.URL('http://good.example/p').with_scheme('http://evil.example')renders ashttp://evil.example://good.example/p, which parses back to hostevil.examplewhile the object it came from still reportsgood.example; the same holds forURL.build. Both entry points now run the scheme throughALPHA *( ALPHA / DIGIT / "+" / "-" / "." )before it is stored, which is where the host subcomponent is already validated.Are there changes in behavior for the user?
Yes. A scheme outside the RFC 3986 grammar now raises
ValueErrorinstead of producing a URL that renders differently than it parses. An empty scheme still means a relative URL, andencoded=Truestill skips validation, matching howhostis handled.Is it a substantial burden for the maintainers to support this?
No, it is one grammar check shared by the two unencoded entry points.
Related issue number
None.
Checklist
CONTRIBUTORS.txt(N/A, no such file in this repo)CHANGES/folder