[WebSocket] Prevent division by 0 in Hixie handshake
This commit is contained in:
parent
3030c81f03
commit
92f3844a53
@ -103,6 +103,10 @@ class Hixie76 implements VersionInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function generateKeyNumber($key) {
|
public function generateKeyNumber($key) {
|
||||||
|
if (0 === substr_count($key, ' ')) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return preg_replace('[\D]', '', $key) / substr_count($key, ' ');
|
return preg_replace('[\D]', '', $key) / substr_count($key, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ class Hixie76Test extends \PHPUnit_Framework_TestCase {
|
|||||||
return array(
|
return array(
|
||||||
array(179922739, '17 9 G`ZD9 2 2b 7X 3 /r90')
|
array(179922739, '17 9 G`ZD9 2 2b 7X 3 /r90')
|
||||||
, array(906585445, '3e6b263 4 17 80')
|
, array(906585445, '3e6b263 4 17 80')
|
||||||
|
, array(0, '3e6b26341780')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user