File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,10 +52,16 @@ private function parseMessage($message)
5252 } else {
5353 $ pos = strpos ($ line , ': ' );
5454 if ($ pos === false ) {
55- throw new \UnexpectedValueException ('Parse error, no colon in line " ' . $ line . '" found ' );
55+ if (substr ($ line , -1 , 1 ) == ': ' ) {
56+ $ key = substr ($ line , 0 , -1 );
57+ $ value = "" ;
58+ } else {
59+ throw new \UnexpectedValueException ('Parse error, no colon in line " ' . $ line . '" found ' );
60+ }
61+ } else {
62+ $ value = substr ($ line , $ pos + 2 );
63+ $ key = substr ($ line , 0 , $ pos );
5664 }
57- $ value = substr ($ line , $ pos + 2 );
58- $ key = substr ($ line , 0 , $ pos );
5965 }
6066
6167 if (isset ($ fields [$ key ])) {
Original file line number Diff line number Diff line change @@ -134,4 +134,12 @@ public function testParsingInvalidResponseNoSpaceAfterColonFails()
134134
135135 $ parser ->push ("Response:NoSpace \r\n\r\n" );
136136 }
137+
138+ public function testParsingEmptyValue ()
139+ {
140+ $ parser = new Parser ();
141+ $ this ->assertEquals (array (), $ parser ->push ("Asterisk Call Manager/1.3 \r\n" ));
142+
143+ $ parser ->push ("Response: \r\n\r\n" );
144+ }
137145}
You can’t perform that action at this time.
0 commit comments