Skip to content

Commit aa0ba44

Browse files
committed
cleanup preg regexps
forward slash does not need to be escaped if the pattern separator is not forward slash itself
1 parent 502485d commit aa0ba44

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/Saml2/Utils.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public static function redirect($url, $parameters = array(), $stay = false)
253253
}
254254

255255
/* Verify that the URL is to a http or https site. */
256-
if (!preg_match('@^https?:\/\/@i', $url)) {
256+
if (!preg_match('@^https?://@i', $url)) {
257257
throw new OneLogin_Saml2_Error(
258258
'Redirect to invalid URL: ' . $url,
259259
OneLogin_Saml2_Error::REDIRECT_INVALID_URL
@@ -306,7 +306,7 @@ public static function setBaseURL($baseurl)
306306
{
307307
if (!empty($baseurl)) {
308308
$baseurlpath = '/';
309-
if (preg_match('#^https?:\/\/([^\/]*)\/?(.*)#i', $baseurl, $matches)) {
309+
if (preg_match('#^https?://([^/]*)/?(.*)#i', $baseurl, $matches)) {
310310
if (strpos($baseurl, 'https://') === false) {
311311
self::setSelfProtocol('http');
312312
$port = '80';
@@ -587,7 +587,7 @@ public static function getSelfURL()
587587
if (!empty($_SERVER['REQUEST_URI'])) {
588588
$requestURI = $_SERVER['REQUEST_URI'];
589589
if ($requestURI[0] !== '/') {
590-
if (preg_match('#^https?:\/\/[^\/]*(\/.*)#i', $requestURI, $matches)) {
590+
if (preg_match('#^https?://[^/]*(/.*)#i', $requestURI, $matches)) {
591591
$requestURI = $matches[1];
592592
}
593593
}

0 commit comments

Comments
 (0)