diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 029a949e1..41f3cc4d0 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -870,7 +870,7 @@ class Router { $output = self::_handleNoRoute($url); } } else { - if (preg_match('/:\/\/|^(javascript|mailto|tel|sms):|^\#/i', $url)) { + if (preg_match('/^([a-z][a-z0-9.+\-]+:|:?\/\/|[#?])/i', $url)) { return $url; } if (substr($url, 0, 1) === '/') { diff --git a/lib/Cake/Test/Case/Routing/RouterTest.php b/lib/Cake/Test/Case/Routing/RouterTest.php index 449a76fab..d5379e536 100644 --- a/lib/Cake/Test/Case/Routing/RouterTest.php +++ b/lib/Cake/Test/Case/Routing/RouterTest.php @@ -2555,6 +2555,9 @@ class RouterTest extends CakeTestCase { $url = '://example.com'; $this->assertEquals($url, Router::url($url)); + $url = '//example.com'; + $this->assertEquals($url, Router::url($url)); + $url = 'javascript:void(0)'; $this->assertEquals($url, Router::url($url)); @@ -2566,6 +2569,10 @@ class RouterTest extends CakeTestCase { $url = '#here'; $this->assertEquals($url, Router::url($url)); + + $url = '?param=0'; + $this->assertEquals($url, Router::url($url)); + $url = 'posts/index#here'; $expected = FULL_BASE_URL . '/posts/index#here'; $this->assertEquals($expected, Router::url($url, true));