Skip to content
Extraits de code Groupes Projets
Valider e8ed8953 rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Correctly parse URL schemes in UrlHelper::isLookLikeUrl().

parent f7678c9f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -107,8 +107,8 @@ class UrlHelper ...@@ -107,8 +107,8 @@ class UrlHelper
*/ */
public static function isLookLikeUrl($url) public static function isLookLikeUrl($url)
{ {
return preg_match('~^((ftp|news|http|https)?:)?//(.*)$~D', $url, $matches) !== 0 return preg_match('~^(([[:alpha:]][[:alnum:]+.-]*)?:)?//(.*)$~D', $url, $matches) !== 0
&& strlen($matches[3]) > 0; && strlen($matches[3]) > 0;
} }
/** /**
......
...@@ -30,6 +30,11 @@ class UrlHelperTest extends \PHPUnit_Framework_TestCase ...@@ -30,6 +30,11 @@ class UrlHelperTest extends \PHPUnit_Framework_TestCase
array('https://www.tëteâ.org', true), array('https://www.tëteâ.org', true),
array('http://汉语/漢語.cn', true), //chinese 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 // valid network-path reference RFC3986
array('//piwik.org', true), array('//piwik.org', true),
array('//piwik/hello?world=test&test', true), array('//piwik/hello?world=test&test', true),
...@@ -45,7 +50,7 @@ class UrlHelperTest extends \PHPUnit_Framework_TestCase ...@@ -45,7 +50,7 @@ class UrlHelperTest extends \PHPUnit_Framework_TestCase
array('jmleslangues.php', false), array('jmleslangues.php', false),
array('http://', false), array('http://', false),
array(' http://', false), array(' http://', false),
array('testhttp://test.com', false), array('2fer://', false),
); );
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter