Fix: don't split URI params inside quoted-string values#135
Open
nixfeo-root wants to merge 1 commit into
Open
Conversation
parse_params currently splits on ';' unconditionally, so RFC 3261 quoted-string param values containing a semicolon (gen-value = token / host / quoted-string, e.g. ;x-route="a;b") are broken into two invalid params. The mis-parse is invisible in Display round-trips (the broken halves re-join with ';' separators and reconstruct the original text) — it only shows up in param count/values, which is what dialog and registrar logic reads. This adds a small quote-aware splitter (no new allocation beyond the existing Vec, no regex/nom dependency). Unquoted input splits exactly as before; a dangling unbalanced quote degrades to the previous behavior instead of erroring. Tests: quoted value with inner ';' stays one param; real-world Linphone Contact ;+sip.instance="<urn:uuid:...>" shape; unquoted multi-param unchanged; dangling-quote graceful degradation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
parse_params(src/sip/uri.rs) splits the param string on;unconditionally, so an RFC 3261 quoted-string param value containing a semicolon is broken into two bogus params:The mis-parse is easy to miss because it is invisible in Display round-trips — the two broken halves re-join with
;separators and reconstruct the original text. It only shows up in param count/values, which is exactly what dialog/registrar logic reads.Per RFC 3261 §25.1,
generic-param = token [ EQUAL gen-value ]withgen-value = token / host / quoted-string, so semicolons inside quoted values are legal. Real-world traffic in this class includes Linphone's Contact;+sip.instance="<urn:uuid:…>"(survives today only because it happens to contain no inner;) and proprietary ITSP params.Fix
A small quote-aware splitter used by
parse_params:Vec, no regex/nom dependency;sip::uritests pass unchanged);Tests
4 new tests in
sip::uri::tests:;stays one param with the value intact;+sip.instanceshape;cargo test --lib sip::uri: 30 passed. (Thedialog::tests::test_client_dialogfailures I see locally are present on pristinemainin my environment too — unrelated to this change.)Context: we're adopting rsipstack as the SIP stack for a production Rust CPaaS (replacing a vendored rsip fork that carried a nom-based version of this same fix) — happy to adjust style/scope as you prefer.