Skip to content

fix(uri): keep existing escapes when printing the user and password - #257

Merged
shenjinti merged 1 commit into
restsend:mainfrom
andreinknv:fix/uri-keep-escapes
Nov 16, 2026
Merged

shenjinti merged 1 commit into
restsend:mainfrom
andreinknv:fix/uri-keep-escapes

Conversation

@andreinknv

Copy link
Copy Markdown
Contributor

Fixes #256.

Uri's Display escaped the % of escapes that the parser keeps as written, so printing a parsed URI turned alice%40example.com into alice%2540example.com, a different user, and every parse/print cycle added another layer. This affected every URI that is parsed and printed again, including a received Contact used as the remote target of in-dialog requests.

The escaper now writes an existing %HH escape unchanged and escapes the remaining octets that RFC 3261 section 25.1 does not allow unescaped, including a % that starts no escape. It also writes the hex digits from a table instead of format!.

Tests

  • uri_display_keeps_escapes_from_the_wire: RFC 4475 esc01, an escaped @, *72# as %2A72%23, and a user with a password print unchanged and stay unchanged when parsed and printed again; a bare % is escaped once. It fails on main and passes with the change.
  • The existing uri_display_percent_encodes_user_and_password still passes.
  • cargo test passes (656 library tests and the integration tests; the interop suite stays ignored).

AI assistance: I used an AI coding assistant to help find this with fuzzing, write the patch and draft this text; I reviewed and tested the change.

Uri's Display escaped the '%' of escapes the parser keeps as written, so
printing a parsed URI turned alice%40example.com into alice%2540example.com
(a different user), and each parse/print cycle added another layer. This
affected every URI parsed and printed again, such as a received Contact used
as the Request-URI of in-dialog requests.

Write an existing %HH escape unchanged and escape only the octets RFC 3261
section 25.1 does not allow unescaped, including a '%' that starts no escape.
Write the hex digits from a table instead of format!.
@shenjinti shenjinti closed this Nov 16, 2026
@shenjinti shenjinti reopened this Nov 16, 2026
@shenjinti
shenjinti merged commit 06f68d3 into restsend:main Nov 16, 2026
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.

Printing a parsed URI escapes the % of existing escapes (alice%40example.com becomes alice%2540example.com)

2 participants