Skip to content
Snippets Groups Projects
Commit f779db4a authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Move SimpleSAML_Utilities::normalizeURL() to...

Move SimpleSAML_Utilities::normalizeURL() to SimpleSAML\Utils\HTTP::normalizeURL() and deprecate the former.
parent 712c56b9
No related branches found
No related tags found
No related merge requests found
......@@ -559,25 +559,10 @@ class SimpleSAML_Utilities {
/**
* Normalizes a URL to an absolute URL and validate it.
*
* In addition to resolving the URL, this function makes sure that it is
* a link to a http or https site.
*
* @param string $url The relative URL.
* @return string An absolute URL for the given relative URL.
* @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::normalizeURL() instead.
*/
public static function normalizeURL($url) {
assert('is_string($url)');
$url = SimpleSAML_Utilities::resolveURL($url, SimpleSAML_Utilities::selfURL());
/* Verify that the URL is to a http or https site. */
if (!preg_match('@^https?://@i', $url)) {
throw new SimpleSAML_Error_Exception('Invalid URL: ' . $url);
}
return $url;
return \SimpleSAML\Utils\HTTP::normalizeURL($url);
}
......
......@@ -428,6 +428,35 @@ class HTTP
}
/**
* Normalizes a URL to an absolute URL and validate it. In addition to resolving the URL, this function makes sure
* that it is a link to an http or https site.
*
* @param string $url The relative URL.
*
* @return string An absolute URL for the given relative URL.
* @throws \SimpleSAML_Error_Exception If $url is not a string or a valid URL.
*
* @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
* @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
*/
public static function normalizeURL($url)
{
if (!is_string($url)) {
throw new \SimpleSAML_Error_Exception('Invalid input parameters.');
}
$url = self::resolveURL($url, self::getSelfURL());
// verify that the URL is to a http or https site
if (!preg_match('@^https?://@i', $url)) {
throw new \SimpleSAML_Error_Exception('Invalid URL: '.$url);
}
return $url;
}
/**
* Parse a query string into an array.
*
......
......@@ -2,7 +2,7 @@
if (isset($_REQUEST['retryURL'])) {
$retryURL = (string)$_REQUEST['retryURL'];
$retryURL = SimpleSAML_Utilities::normalizeURL($retryURL);
$retryURL = \SimpleSAML\Utils\HTTP::normalizeURL($retryURL);
} else {
$retryURL = NULL;
}
......
......@@ -6,7 +6,7 @@ $config = SimpleSAML_Configuration::getInstance();
if(array_key_exists('link_href', $_REQUEST)) {
$link = (string)$_REQUEST['link_href'];
$link = SimpleSAML_Utilities::normalizeURL($link);
$link = \SimpleSAML\Utils\HTTP::normalizeURL($link);
} else {
$link = 'index.php';
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment