lib/rest: fix URLPathEscapeAll encoding RFC 3986 unreserved characters#9241
Open
furmandev wants to merge 1 commit intorclone:masterfrom
Open
lib/rest: fix URLPathEscapeAll encoding RFC 3986 unreserved characters#9241furmandev wants to merge 1 commit intorclone:masterfrom
furmandev wants to merge 1 commit intorclone:masterfrom
Conversation
URLPathEscapeAll was only passing [A-Za-z0-9/] through unencoded, causing it to percent-encode RFC 3986 unreserved characters (-, ., _, ~). Per RFC 3986 §2.3, unreserved characters MUST NOT be percent-encoded, and a URI that unnecessarily encodes them is not equivalent to one that does not. Before: /files/my-report.pdf → /files/my%2Dreport%2Epdf After: /files/my-report.pdf → /files/my-report.pdf Servers that perform strict path matching without normalising percent-encoded characters will reject the over-encoded form, causing unexpected 404 errors for paths containing dots, hyphens, underscores, or tildes.
Member
|
This seems like a reasonable thing to do. Was it causing you an actual problem? If so change the commit message to say
The first line of the commit message goes in the changelog so make it something users would want to read |
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 is the purpose of this change?
URLPathEscapeAllonly passes[A-Za-z0-9/]through unencoded, causing it to percent-encode the RFC 3986 unreserved characters-,.,_, and~.Per RFC 3986 §2.3, unreserved characters MUST NOT be percent-encoded, and a URI that unnecessarily encodes them is not equivalent to one that does not. Servers that perform strict path matching without normalising percent-encoded URIs will reject the over-encoded form with a 404.
This fix adds
-,.,_,~to the set of characters passed through unencoded. Reserved characters (spaces, semicolons, colons,%,?,#, etc.) continue to be encoded as before.Before:
/files/my-report.pdf→/files/my%2Dreport%2EpdfAfter:
/files/my-report.pdf→/files/my-report.pdfWas the change discussed in an issue or in the forum before?
No.
Checklist