Skip to content

Preserve percent-encoded reserved characters during normalization#589

Open
cvx wants to merge 1 commit into
sporkmonger:mainfrom
cvx:fix-normalized-encode-reserved-chars
Open

Preserve percent-encoded reserved characters during normalization#589
cvx wants to merge 1 commit into
sporkmonger:mainfrom
cvx:fix-normalized-encode-reserved-chars

Conversation

@cvx
Copy link
Copy Markdown

@cvx cvx commented Apr 29, 2026

RFC 3986 section 2.2 states that a reserved character and its percent-encoded form are not equivalent, and section 6.2.2.2 only permits decoding unreserved characters during normalization.

Previously decoding and re-encoding URLs was turning %3A into :, %2F into /, etc.

Both normalization methods (URI.normalized_encode and URI#normalize) now pass the reserved characters to normalize_component. Decoding of unreserved characters is unchanged.


NOTE: This is considered a breaking change.

If anyone depended on percent-encoded reserved characters, they'll now have a different output. (more "correct" but still) Also, not public/not documented constants PCHAR, FRAGMENT, QUERY are removed since they're no longer used internally. (fwiw I didn't find any references to those in public repos on github)


Fixes #472
Fixes #424
Fixes #386
Fixes #366
Fixes #295

RFC 3986 section 2.2 states that a reserved character and its percent-encoded form are not equivalent, and section 6.2.2.2 only permits decoding unreserved characters during normalization.

Previously decoding and re-encoding URLs was turning `%3A` into `:`, `%2F` into `/`, etc.

Both normalization methods (`URI.normalized_encode` and `URI#normalize`) now pass the reserved characters to `normalize_component`. Decoding of unreserved characters is unchanged.

---

NOTE: This is considered a breaking change.
If anyone depended on percent-encoded reserved
characters, they'll now have a different output. (more "correct" but still)
Also, not public/not documented constants
`PCHAR`, `FRAGMENT`, `QUERY` are removed since they're no longer used internally. (fwiw I didn't find any refences to those in public repos on github)

---

Fixes sporkmonger#472
Fixes sporkmonger#424
Fixes sporkmonger#386
Fixes sporkmonger#366
Fixes sporkmonger#295
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant