onsip / SIP.js

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

Fail parsing header "From" when user domain starts with number #1055

Open 8clever opened 1 year ago

8clever commented 1 year ago

SIP.js 0.21.2

SyntaxError: Expected "." or [a-z,A-Z,0-9,_,-] but ">" found. (at sip.js?v=:4412:16) at peg$buildStructuredError (sip.js?v=:4412:16) at Module.peg$parse (sip.js?v=:4646:15) at Array. (sip.js?v=:3066:54) at webpack_require (sip.js?v=:21650:41) at Array. (sip.js?v=:538:77) at webpack_require (sip.js?v=:21650:41) at Array. (sip.js?v=:105:72) at __webpack_require__ (sip.js?v=:21650:41) at sip.js?v=:21732:71 at sip.js?v=:21752:3

Problem in header From where user domain starts with number but not IP just a hash

const valid = { input: `"user_1" <sip:1@f0b38bfd0a0d>;tag=2157194f-f14a-4a81-ab94-f2296533f32a`, options: { startRule: "From" }}
const notValid = { input: `"user_1" <sip:1@0fb38bfd0a0d>;tag=2157194f-f14a-4a81-ab94-f2296533f32a`, options: { startRule: "From" }};

You can simply reproduce it just run

pegGrammar.parse(valid.input, valid.options)
pegGrammar.parse(notValid.input. notValid.options)

Not valid will throw error but not should.

douglas444 commented 4 months ago

Did you find a solution? I'm getting the same error with sip:6001@543dc521b9a2;tag=2caf10df-3a4e-440d-9935-4b85f0208eff

I wonder if I can change the way this hash is built somewhere in the asterisk server

douglas444 commented 4 months ago

I found a workaround by setting the following in the endpoint configuration on asterisk pjsip.conf: from_domain=localhost It's not an actual solution, of course. I'm using it to proceed with my localhost tests.