Skip to content

Commit

Permalink
Fixed REFER NOTIFY parsing in accordance to RFC 3515 section 2.4.5 (v…
Browse files Browse the repository at this point in the history
…ersatica#767)

* Fixed REFER NOTIFY parsing to only parse the first line as a status line of a message/sipfrag body in accordance with RFC 3515 section 2.4.5.

* Added a test for status line parsing.
  • Loading branch information
markusatm authored Nov 5, 2022
1 parent 8e240a0 commit 3a90783
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/RTCSession/ReferSubscriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ module.exports = class ReferSubscriber extends EventEmitter
return;
}

const status_line = Grammar.parse(request.body.trim(), 'Status_Line');
const status_line = Grammar.parse(request.body.trim().split('\r\n', 1)[0], 'Status_Line');

if (status_line === -1)
{
Expand Down
11 changes: 11 additions & 0 deletions test/test-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,17 @@ module.exports = {
test.strictEqual(parsed.to_tag, '03aq91cl9n');
test.strictEqual(parsed.from_tag, 'kun98clbf7');

test.done();
},

'parse Status Line' : function(test)
{
const data = 'SIP/2.0 420 Bad Extension';
let parsed;

test.ok((parsed = JsSIP.Grammar.parse(data, 'Status_Line')) !== -1);
test.strictEqual(parsed.status_code, 420);

test.done();
}
};

0 comments on commit 3a90783

Please sign in to comment.