Decode percent-encoded unreserved characters during normalization - #151
Open
gaoflow wants to merge 1 commit into
Open
Decode percent-encoded unreserved characters during normalization#151gaoflow wants to merge 1 commit into
gaoflow wants to merge 1 commit into
Conversation
RFC 3986 Section 6.2.2.2 requires percent-encodings of unreserved characters to be decoded. normalize_percent_characters() only upper-cased them, so normalized_equality() returned False for URIs the RFC treats as equivalent. Reserved and non-ASCII octets stay 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_percent_characters()only upper-cases percent-triples; RFC 3986 §6.2.2.2 also requires decoding triples of unreserved characters (ALPHA / DIGIT / "-" / "." / "_" / "~"). Because the decode step is missing, the library's own equality predicate returns the wrong answer for URIs the RFC treats as equivalent:The fix decodes unreserved triples after the existing upper-case pass. Reserved octets (
%2F,%21, …) and non-ASCII octets (%DF) stay encoded. One visible consequence:%2Ein paths now decodes before dot-segment removal, so/a/%2E%2E/bnormalizes to/bper the RFC's ordering.The module's
UNRESERVED_CHARSconstant also includes!(a sub-delimiter), so the decode set is defined directly from RFC 3986 §2.3.Tests enumerate all 256 octets across userinfo, path, query, and fragment, plus idempotence and
normalized_equality.