[CODEC-339] Escape URLCodec control characters in custom safe sets#433
Merged
garydgregory merged 2 commits intoJun 18, 2026
Conversation
Keep '%' and '+' percent-encoded even when callers mark them safe in URLCodec.encodeUrl(BitSet, byte[]). decodeUrl() treats those bytes as encoding syntax, so emitting them literally can produce undecodable output or break round trips. Reviewed-by: OpenAI Codex Reviewed-by: Anthropic Claude Code
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.
[CODEC-339] URLCodec custom safe sets can emit URL encoding control characters.
This change keeps
%and+percent-encoded inURLCodec.encodeUrl(BitSet, byte[])even when a caller-provided safe-characterBitSetmarks them as safe.decodeUrl(byte[])treats%as the escape prefix and+as a space. AllowingencodeUrl(...)to emit those bytes literally can produce undecodable output (%) or break round-trip behavior (+decodes as space). This patch preserves those characters as URL-encoding syntax and documents that they are always escaped.Tests added:
%marked safe still encodes as%25and decodes back to%.+marked safe still encodes as%2Band decodes back to+.Also updates
src/changes/changes.xmlfor CODEC-339.