Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/UrlHelper.php4
-rw-r--r--tests/PHPUnit/Unit/UrlHelperTest.php7
2 files changed, 8 insertions, 3 deletions
diff --git a/core/UrlHelper.php b/core/UrlHelper.php
index 3a550c8eb3..4a0ac0fa0a 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 49c33cc0df..e972d20d54 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),
);
}