Skip to content

Commit 0e8c5cf

Browse files
committed
Fixed Contact and Record-Route header split.
1 parent 07a082c commit 0e8c5cf

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/Parser.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,14 @@ JsSIP.Parser = (function() {
8787
}
8888
break;
8989
case 'record-route':
90-
header = header_value.split(',');
90+
header = header_value.match(/([^\"\',]*((\'[^\']*\')*||(\"[^\"]*\")*))+/gm);
9191
length = header.length;
9292
parsed = 0;
9393

9494
for(idx=0; idx < length; idx++) {
95-
message.addHeader('record-route', header[idx]);
95+
if (header[idx].length > 0) {
96+
message.addHeader('record-route', header[idx]);
97+
}
9698
}
9799
break;
98100
case 'call-id':
@@ -105,12 +107,17 @@ JsSIP.Parser = (function() {
105107
break;
106108
case 'contact':
107109
case 'm':
108-
header = header_value.split(',');
110+
header = header_value.match(/([^\"\',]*((\'[^\']*\')*||(\"[^\"]*\")*))+/gm);
109111
length = header.length;
110112

111113
for(idx=0; idx < length; idx++) {
112-
message.addHeader('contact', header[idx]);
113-
parsed = message.parseHeader('contact', idx);
114+
if (header[idx].length > 0) {
115+
message.addHeader('contact', header[idx]);
116+
parsed = message.parseHeader('contact', idx);
117+
if (parsed === undefined) {
118+
break;
119+
}
120+
}
114121
}
115122
break;
116123
case 'content-length':

0 commit comments

Comments
 (0)