diff --git a/core/UrlHelper.php b/core/UrlHelper.php index 3a550c8eb30c5e425e5614fa9389dc4c2bae7eb1..4a0ac0fa0ada317c0700127ee7d30ffc7e6b8697 100644 --- a/core/UrlHelper.php +++ b/core/UrlHelper.php @@ -107,8 +107,8 @@ class UrlHelper */ public static function isLookLikeUrl($url) { - return preg_match('~^((ftp|news|http|https)?:)?//(.*)$~D', $url, $matches) !== 0 - && strlen($matches[3]) > 0; + return preg_match('~^(([[:alpha:]][[:alnum:]+.-]*)?:)?//(.*)$~D', $url, $matches) !== 0 + && strlen($matches[3]) > 0; } /** diff --git a/tests/PHPUnit/Unit/UrlHelperTest.php b/tests/PHPUnit/Unit/UrlHelperTest.php index 49c33cc0df22d1d377aba1731bfc5fc29b283985..e972d20d54e0b1a4ab139fdbd48126d3b43505d5 100644 --- a/tests/PHPUnit/Unit/UrlHelperTest.php +++ b/tests/PHPUnit/Unit/UrlHelperTest.php @@ -30,6 +30,11 @@ class UrlHelperTest extends \PHPUnit_Framework_TestCase array('https://www.tëteâ.org', true), array('http://汉è¯/漢語.cn', true), //chinese + array('rtp://whatever.com', true), + array('testhttp://test.com', true), + array('cylon://3.hmn', true), + array('://something.com', true), + // valid network-path reference RFC3986 array('//piwik.org', true), array('//piwik/hello?world=test&test', true), @@ -45,7 +50,7 @@ class UrlHelperTest extends \PHPUnit_Framework_TestCase array('jmleslangues.php', false), array('http://', false), array(' http://', false), - array('testhttp://test.com', false), + array('2fer://', false), ); }