Skip to content

Grammar: maddr no longer overwrites the URI host; ttl is stored as a URI parameter - #1133

Open
AhmedElbashier wants to merge 1 commit into
onsip:mainfrom
AhmedElbashier:fix/uri-maddr-ttl-params
Open

AhmedElbashier wants to merge 1 commit into
onsip:mainfrom
AhmedElbashier:fix/uri-maddr-ttl-params

Conversation

@AhmedElbashier

@AhmedElbashier AhmedElbashier commented Nov 26, 2026 •

Copy link
Copy Markdown

Fixes the first part of #1132 (maddr / ttl). The user-part escaping and trailing-dot FQDN items in that issue are separate changes and are not touched here.

Problem

  • maddr_param (and via_maddr) parse their value with the host rule. That rule's action sets options.data.host, so the maddr value replaces the URI host before new URI(...) runs in SIP_URI. The same thing happens to the Via sent-by host.
  • ttl_param writes to options.data.params instead of options.data.uri_params. The ttl is dropped from the URI, and when the URI is inside a name-addr (Contact, To, From...) it ends up as a header parameter.

On main:

Grammar.URIParse("sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15").toString();
// "sip:alice@239.255.255.1;maddr=239.255.255.1"

Grammar.parse("<sip:alice@atlanta.com;ttl=15>;expires=60", "Contact")[0].parsed.parameters;
// { ttl: "15", expires: "60" }

Grammar.parse("SIP/2.0/UDP pc33.atlanta.com;maddr=224.2.0.1;branch=z9hG4bK776asdhds", "Via").host;
// "224.2.0.1"

Change

  • New maddr_host rule: same alternatives as host (hostname / IPv4address / IPv6reference) but it only returns the text. It does not store host, and it restores host_type so that keeps describing the real host. Used by maddr_param and via_maddr.
  • ttl_param stores into uri_params.

After the change the examples give sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15, Contact params { expires: "60" } with ttl on the URI, and Via host pc33.atlanta.com (host_type: "domain", maddr: "224.2.0.1").

Tests

Added a URI maddr and ttl parameters block to test/spec/core/grammar.spec.ts (RFC 3261 §19.1.3 example URI, the Contact case and the Via case). They fail on main and pass with the change. The rest of the Core/API specs pass locally. In my headless Chrome sandbox the Web SessionDescriptionHandler specs fail at media setup. That suite doesn't touch the grammar (see also #1128). eslint and prettier --check are clean on the touched files.

maddr_param and via_maddr reused the host rule, whose action stores
options.data.host, so a maddr value replaced the URI host (and the Via
sent-by host). Parse maddr with a rule that has no host side effect and
keeps host_type.

ttl_param wrote to options.data.params instead of uri_params, so the ttl
was lost from the URI and, inside a name-addr, showed up as a header
parameter.

Part of onsip#1132.
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