Repository navigation
fix(uri): keep existing escapes when printing the user and password - #257
Merged
Merged
Conversation
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!.
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.
Fixes #256.
Uri'sDisplayescaped the%of escapes that the parser keeps as written, so printing a parsed URI turnedalice%40example.comintoalice%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
%HHescape 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 offormat!.Tests
uri_display_keeps_escapes_from_the_wire: RFC 4475esc01, 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 onmainand passes with the change.uri_display_percent_encodes_user_and_passwordstill passes.cargo testpasses (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.