Percent-encode pipe character in URL paths#3764
Open
Mr-Neutr0n wants to merge 1 commit intoencode:masterfrom
Open
Percent-encode pipe character in URL paths#3764Mr-Neutr0n wants to merge 1 commit intoencode:masterfrom
Mr-Neutr0n wants to merge 1 commit intoencode:masterfrom
Conversation
the | character was not being percent-encoded in path segments, even though it's not a valid pchar per RFC 3986. this caused issues with servers that reject or redirect URLs with unencoded pipes. now | gets encoded as %7C in paths, matching the behavior of Python's urllib and the requests library.
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.
Fixes #3565.
The
|character wasn't being percent-encoded in path segments, even though it's not a validpcharper RFC 3986. Some servers reject or redirect URLs that contain an unencoded pipe — which is what the original reporter ran into (getting a 301 redirect when switching fromrequeststohttpx).This removes
|(U+007C) from thePATH_SAFEset so it gets encoded as%7C, matching the behavior of Python'surllib.parse.quoteand therequestslibrary.The WHATWG URL spec technically allows
|unencoded in paths, so I've skipped the 3 WHATWG conformance test cases that expect an unencoded pipe in the pathname. Added a regression test covering bothraw_pathandpathproperties.