normalize: decode %2E in a path segment that isn't a dot-segment - #212
Open
dngr2 wants to merge 1 commit into
Open
normalize: decode %2E in a path segment that isn't a dot-segment#212dngr2 wants to merge 1 commit into
dngr2 wants to merge 1 commit into
Conversation
normalizePathEncoding kept every %2E percent-encoded to stop %2E%2E from decoding into .. and being collapsed by removeDotSegments. That suppressed %2E everywhere, so foo%2Ebar and %2Ehidden stayed encoded even though . is unreserved (RFC 3986 2.3) and should be decoded (6.2.2.2) — the query and fragment normalizers already do, and equal() reported RFC-equivalent URIs as unequal. Decide per segment: keep %2E encoded only when the segment is . or .., decode it otherwise, so the %2E%2E traversal stays encoded.
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.
normalize()leaves%2Epercent-encoded everywhere in the path, sohttp://h/foo%2Ebarstaysfoo%2Ebarandequal('.../foo%2Ebar', '.../foo.bar')returns false. But.is unreserved (RFC 3986 §2.3) and should be decoded (§6.2.2.2) — the query and fragment normalizers already do, and every other unreserved byte (-_~) is decoded in the path.The blanket
decoded !== '.'guard exists to stop%2E%2Efrom decoding into..and being collapsed byremoveDotSegments(a traversal defense), but it is too broad. This decides per segment:%2Estays encoded only when the segment is exactly.or.., and decodes otherwise./public/%2E%2E/adminis unchanged and the security-normalization tests still pass.