-
Notifications
You must be signed in to change notification settings - Fork 3
Description
A Contact: header in a response to REGISTER request may contain one or more values separated by commas, like this:
Contact: <sip:[email protected]:55497;transport=tls>;expires=111;received="sip:[email protected]:55497";reg-id=1;+sip.instance="<d79966b435633699badcf12507380d51d4e97eab>",<sip:[email protected]:17127;transport=tls>;expires=258;received="sip:[email protected]:17127";reg-id=2;+sip.instance="<65be01c100f2ccd762df61057569f037bd46a367>"
This actually happens in practice if the indicated user is registered from multiple devices.
The StreamParser, as of version 0.7.0., does not anticipate this possibility and will enter an infinite loop in some cases. The main problem seems to be that the method
ContactHeader.parse(array $hbody)
receives only an array of count 1, while it should receive an array of count N, exploded by the delimiter ,.
I made a crude and ugly fix in ContactHeader.parse like this:
public static function parse(array $hbody): ContactHeader
{
$ret = new static;
$hbody2 = array();
foreach ($hbody as $hline) {
$explodedLine = explode(',', $hline);
$hbody2 = array_merge($hbody2, $explodedLine);
}
$hbody = $hbody2;
It works, but it is also very ugly. I suppose that the original author has a better solution.
AFAIK, in case of SIP, if a header contains commas, it is as if the same header was present multiple times, so
Contact: XX,YY
is equivalent to
Contact: XX
Contact: YY