onsip / SIP.js

A simple, intuitive, and powerful JavaScript signaling library
https://sipjs.com
MIT License
1.84k stars 693 forks source link

Tel-uri cause sip.parser to throw error #953

Open ErikKalstrom opened 2 years ago

ErikKalstrom commented 2 years ago

Describe the bug Make a SIP-Register on a user that has multiple registed devices. Some desktop terminals.

Logs REGISTER sip:anonymous.invalid SIP/2.0 Via: SIP/2.0/WSS ogj1ts1jtj1u.invalid;branch=z9hG4bK615348 To: sip:3017@xyz.se From: sip:3017@xyz.se;tag=52103rvmfn CSeq: 3 REGISTER Call-ID: 5aqm5lq9us752mhp7qm7 Max-Forwards: 70 Authorization: Digest algorithm=MD5, username="erik@xyz.se", realm="127.0.0.1", nonce="91eb0ca7ced99582", uri="sip:anonymous.invalid", response="dbf5bc3da5e979dcd82d04099c916beb", opaque="b9939a8796a9ce83cdcfcdced2cecfd2cecbabcecac5cdc6c5cdc6d1c9ccc8c8c7cec9a583", qop=auth, cnonce="2i0dga3u7gc5", nc=00000001 Contact: sip:6cmlnq4d@ogj1ts1jtj1u.invalid;transport=ws;+webrtc;expires=180 Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER Supported: outbound, path, gruu User-Agent: xyz WebRTC client/0.1 Content-Length: 0

200 - OK

SIP/2.0 200 OK Via: SIP/2.0/WSS ogj1ts1jtj1u.invalid;branch=z9hG4bK615348 To: sip:3017@xyz.se;tag=xyze39dcf991d1e41d9b5 From: sip:3017@xyz.se;tag=52103rvmfn Call-ID: 5aqm5lq9us752mhp7qm7 CSeq: 3 REGISTER Max-Forwards: 70 Accept: application/csta+xml,application/sdp,application/x-as-feature-event+xml,application/dtmf-relay,application/pidf+xml Allow-Events: b2buaCSTA,as-feature-event,dialog,presence,message-summary,reg,refer Allow: NOTIFY,REFER,MESSAGE,UPDATE,SUBSCRIBE,REGISTER,INVITE,CANCEL,BYE,ACK,PUBLISH Supported: norefersub,replaces,timer Contact: sip:6cmlnq4d@ogj1ts1jtj1u.invalid;transport=ws;expires=180 Contact: <tel:+46000003017>;expires=31366253 Contact: <tel:+46000000401>;expires=31366253 Date: Thu, 14 Oct 2021 15:29:29 GMT Organization: ROOT xyz Server: xyz Gateway/1.0.0.0 Content-Length: 0

This throws an error: sip.Parser | error parsing header 'Contact'

And I think it has something to do with the grammar that not supports Tel-uris

Multiply contacts in a 200 response on Sip-registered is not uncommon but in this case I think its the Tel-schema that is not supported?

Can you add this support?

john-e-riordan commented 1 year ago

Yes. Should parse and should be handled. Apparently a bug. Needs investigation.

Contact        =  ("Contact" / "m" ) HCOLON
                  ( STAR / (contact-param *(COMMA contact-param)))
contact-param  =  (name-addr / addr-spec) *(SEMI contact-params)
name-addr      =  [ display-name ] LAQUOT addr-spec RAQUOT
addr-spec      =  SIP-URI / SIPS-URI / absoluteURI

absoluteURI    =  scheme ":" ( hier-part / opaque-part )

opaque-part    =  uric-no-slash *uric
uric           =  reserved / unreserved / escaped
uric-no-slash  =  unreserved / escaped / ";" / "?" / ":" / "@"
                  / "&" / "=" / "+" / "$" / ","