diff --git a/lib/Ratchet/Application/WebSocket/Version/RFC6455/HandshakeVerifier.php b/lib/Ratchet/Application/WebSocket/Version/RFC6455/HandshakeVerifier.php index 13e8c59..224e870 100644 --- a/lib/Ratchet/Application/WebSocket/Version/RFC6455/HandshakeVerifier.php +++ b/lib/Ratchet/Application/WebSocket/Version/RFC6455/HandshakeVerifier.php @@ -49,10 +49,18 @@ class HandshakeVerifier { /** * @param string * @return bool - * @todo Implement this functionality + * @todo Verify the logic here is correct */ public function verifyRequestURI($val) { - return true; + if ($val[0] != '/') { + return false; + } + + if (false !== strstr($val, '#')) { + return false; + } + + return mb_check_encoding($val, 'ASCII'); } /** diff --git a/tests/Ratchet/Tests/Application/WebSocket/Version/RFC6455/HandshakeVerifierTest.php b/tests/Ratchet/Tests/Application/WebSocket/Version/RFC6455/HandshakeVerifierTest.php index 217e984..8d5304f 100644 --- a/tests/Ratchet/Tests/Application/WebSocket/Version/RFC6455/HandshakeVerifierTest.php +++ b/tests/Ratchet/Tests/Application/WebSocket/Version/RFC6455/HandshakeVerifierTest.php @@ -57,12 +57,13 @@ class HandshakeVerifierTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($expected, $this->_v->verifyHTTPVersion($in)); } - /** - * @todo Add failing values in here - */ public static function uRIProvider() { return array( array(true, '/chat') + , array(true, '/hello/world?key=val') + , array(false, '/chat#bad') + , array(false, 'nope') + , array(false, '/ ಠ_ಠ ') ); } @@ -70,8 +71,6 @@ class HandshakeVerifierTest extends \PHPUnit_Framework_TestCase { * @dataProvider URIProvider */ public function testRequestUri($expected, $in) { - return $this->markTestIncomplete('Method this test is testing is incomplete'); - $this->assertEquals($expected, $this->_v->verifyRequestURI($in)); }