Skip to content

[CODEC-338] Escape literal plus with plusForSpace#432

Open
OldTruckDriver wants to merge 1 commit into
apache:masterfrom
OldTruckDriver:fix/CODEC-338_literal_plus
Open

[CODEC-338] Escape literal plus with plusForSpace#432
OldTruckDriver wants to merge 1 commit into
apache:masterfrom
OldTruckDriver:fix/CODEC-338_literal_plus

Conversation

@OldTruckDriver

Copy link
Copy Markdown

[CODEC-338] PercentCodec loses literal '+' when plusForSpace is enabled.

This change makes PercentCodec percent-encode a literal '+' as %2B when plusForSpace is enabled. In that mode, decoding treats '+' as a space, so leaving a literal plus unescaped made the encoded output ambiguous and broke round-trip behavior.

The fix adds '+' to the always-encode character set when plusForSpace is true. Spaces are still encoded as '+', while literal plus signs are preserved as %2B.

Tests added:

  • "a+b c" encodes to "a%2Bb+c" and round-trips.
  • "a+b" encodes to "a%2Bb" and round-trips, covering the no-space boundary case.

Also updates src/changes/changes.xml for CODEC-338.

When plusForSpace is enabled, decoding treats '+' as a space. Mark '+' as an always-encoded character for that mode so encoding emits a literal plus as %2B and preserves round trips.

Reviewed-by: OpenAI Codex
Reviewed-by: Anthropic Claude Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant