Skip to content
Extraits de code Groupes Projets
Valider 6cb72fcb rédigé par mattab's avatar mattab
Parcourir les fichiers

Fixes #8290 escape trusted hosts before calling preg_match to prevent PHP warning

parent 691492e1
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -240,9 +240,12 @@ class Url ...@@ -240,9 +240,12 @@ class Url
return true; return true;
} }
// Escape trusted hosts for preg_match call below
foreach ($trustedHosts as &$trustedHost) { foreach ($trustedHosts as &$trustedHost) {
$trustedHost = preg_quote($trustedHost); $trustedHost = preg_quote($trustedHost);
} }
$trustedHosts = str_replace("/", "\\/", $trustedHosts);
$untrustedHost = Common::mb_strtolower($host); $untrustedHost = Common::mb_strtolower($host);
$untrustedHost = rtrim($untrustedHost, '.'); $untrustedHost = rtrim($untrustedHost, '.');
......
...@@ -231,6 +231,8 @@ class UrlTest extends \PHPUnit_Framework_TestCase ...@@ -231,6 +231,8 @@ class UrlTest extends \PHPUnit_Framework_TestCase
array(false, 'www.example.com:8080', array('example.com'), 'host:port is valid'), array(false, 'www.example.com:8080', array('example.com'), 'host:port is valid'),
array(true, 'www.example.com:8080', array('example.com:8080'), 'host:port is valid'), array(true, 'www.example.com:8080', array('example.com:8080'), 'host:port is valid'),
array(false, 'www.whatever.com', array('*.whatever.com'), 'regex char is escaped'), array(false, 'www.whatever.com', array('*.whatever.com'), 'regex char is escaped'),
array(false, 'www.whatever.com', array('www.whatever.com/abc'), 'with path starting with /a does not throw error'),
array(false, 'www.whatever.com', array('www.whatever.com/path/here'), 'with path starting with /p does not throw error'),
); );
} }
......
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