Skip to content

Commit

Permalink
sip uri parser fails to parse sip:+1234@feature-server
Browse files Browse the repository at this point in the history
  • Loading branch information
davehorton committed Nov 6, 2023
1 parent bd10cd1 commit d99006f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/sip-parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ function parseUri(s) {
// eslint-disable-next-line max-len
//const re = /^(sips?):(?:([^\s>:@]+)(?::([^\s@>]+))?@)?([\w\-\.]+)(?::(\d+))?((?:;[^\s=\?>;]+(?:=[^\s?\;]+)?)*)(?:\?(([^\s&=>]+=[^\s&=>]+)(&[^\s&=>]+=[^\s&=>]+)*))?$/;
// eslint-disable-next-line max-len
const re = /^(sips?):(?:([^\s>:@]+)(?::([^\s@>]+))?@)?(?:(|(?:\[.*\])|(?:[0-9A-Za-z\-_]+\.)+[0-9A-Za-z\-_]+)|(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(?::(\d+))?((?:;[^\s=\?>;]+(?:=[^\s?\;]+)?)*)(?:\?(([^\s&=>]+=[^\s&=>]+)(&[^\s&=>]+=[^\s&=>]+)*))?$/;
const re = /^(sips?):(?:([^\s>:@]+)(?::([^\s@>]+))?@)?(?:(|(?:\[.*\])|(?:[0-9A-Za-z\-_]+\.)*[0-9A-Za-z\-_]+)|(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(?::(\d+))?((?:;[^\s=\?>;]+(?:=[^\s?\;]+)?)*)(?:\?(([^\s&=>]+=[^\s&=>]+)(&[^\s&=>]+=[^\s&=>]+)*))?$/;
// eslint-disable-next-line max-len
//const re = /^(sips?):(?:([^\s>:@]+)(?::([^\s@>]+))?@)?((?:[0-9A-Za-z\-_]+\.)?[0-9A-Za-z\-_]+|(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|\[(?:[A-Fa-f0-9:]+)\])(?::(\d+))?((?:;[^\s=\?>;]+(?:=[^\s?\;]+)?)*)(?:\?(([^\s&=>]+=[^\s&=>]+)(&[^\s&=>]+=[^\s&=>]+)*))?$/;


const r = re.exec(s);

Expand Down
7 changes: 7 additions & 0 deletions test/unit-tests/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ describe('Parser', function () {
uri.user.should.eql('116751x0');
uri.scheme.should.eql('sips');
});
it('should parse a sip uri with host part being simple label', function () {
var uri = parseUri('sip:116751@feature-server');
uri.family.should.eql('ipv4');
uri.host.should.eql('feature-server');
uri.user.should.eql('116751');
uri.scheme.should.eql('sip');
});
it('should parse a multi-part header', function () {
var msg = new SipMessage(examples('siprec'));
msg.payload.length.should.eql(2);
Expand Down

0 comments on commit d99006f

Please sign in to comment.