Skip to content

[next_url] misparses Contact with nested angle brackets (+sip.instance) #860

@Rezashelby

Description

@Rezashelby

What [next_url] is supposed to do

SIPp extracts the URI from the Contact: header of the last received response to build the Request-URI for ACK and BYE. It looks for the first < and matching >.


The problematic Contact header

RFC 5626 endpoints (e.g. Linphone, Cisco) include +sip.instance in Contact:

Contact: sip:[email protected]:5060;+sip.instance="urn:uuid:5f93b700-4b89-1039-8e5a-ea8def123456"

There are two pairs of angle brackets here:

  1. sip:[email protected]:5060 — the SIP URI (what SIPp should extract)
  2. urn:uuid:5f93b700-... — inside the quoted +sip.instance value

What SIPp does (wrong)

SIPp finds < at position 9, then scans forward for > — but it finds the first > it encounters, which is the one closing urn:uuid:...:

Contact: sip:[email protected]:5060;+sip.instance="urn:uuid:5f93b700-4b89-1039-8e5a-ea8def123456"
^ ^
opens here SIPp stops here -------- wrong closing >----------+

So [next_url] expands to:

sip:[email protected]:5060>;+sip.instance="<urn:uuid:5f94a240-4b89-1039-8e5a-ea8def123456

And the generated ACK looks like:

ACK sip:[email protected]:5060>;+sip.instance="<urn:uuid:5f93b700-4b89-1039-8e5a-ea8def123456 SIP/2.0

This is a malformed Request-URI. The SIP server rejects it with a parse error:

parse_param_body(): Error while parsing quoted string


Expected behaviour

SIPp should stop at the > that closes the URI angle bracket (the one immediately after the host:port), ignoring > characters inside quoted strings ("...") that appear in header
parameters.

The correct extraction from:
sip:[email protected]:5060;+sip.instance="urn:uuid:..."
should be: sip:[email protected]:5060

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions