summaryrefslogtreecommitdiffstats
path: root/lib/SimpleSAML
diff options
context:
space:
mode:
Diffstat (limited to 'lib/SimpleSAML')
-rw-r--r--lib/SimpleSAML/Utils/HTTP.php44
1 files changed, 18 insertions, 26 deletions
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index b90a793..186ee6e 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -709,31 +709,30 @@ class HTTP
/**
- * Retrieve the current, complete URL.
+ * Retrieve the current URL using the base URL in the configuration.
*
* @return string The current URL, including query parameters.
*
* @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no>
* @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
+ * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
*/
public static function getSelfURL()
{
- $url = self::getSelfURLHost();
- $requestURI = $_SERVER['REQUEST_URI'];
- if ($requestURI[0] !== '/') {
- // we probably have a URL of the form: http://server/
- if (preg_match('#^https?://[^/]*(/.*)#i', $requestURI, $matches)) {
- $requestURI = $matches[1];
- }
- }
- return $url.$requestURI;
+ $url = self::getBaseURL();
+ $cfg = \SimpleSAML_Configuration::getInstance();
+ $baseDir = $cfg->getBaseDir();
+ $rel_path = str_replace($baseDir.'www/', '', $_SERVER['SCRIPT_FILENAME']);
+ $pos = strpos($_SERVER['REQUEST_URI'], $rel_path) + strlen($rel_path);
+ return $url.$rel_path.substr($_SERVER['REQUEST_URI'], $pos);
}
/**
- * Retrieve a URL containing the protocol, the current host and optionally, the port number.
+ * Retrieve the current URL using the base URL in the configuration, containing the protocol, the host and
+ * optionally, the port number.
*
- * @return string The current URL without a URL path or query parameters.
+ * @return string The current URL without path or query parameters.
*
* @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no>
* @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
@@ -748,28 +747,21 @@ class HTTP
/**
- * Retrieve the current URL without the query parameters.
+ * Retrieve the current URL using the base URL in the configuration, without the query parameters.
*
* @return string The current URL, not including query parameters.
*
* @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no>
+ * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
*/
public static function getSelfURLNoQuery()
{
- $url = self::getSelfURLHost();
- $url .= $_SERVER['SCRIPT_NAME'];
-
- /* In some environments, $_SERVER['SCRIPT_NAME'] already ends with $_SERVER['PATH_INFO']. Only append
- * $_SERVER['PATH_INFO'] if it's set and missing from script name.
- *
- * Contributed by Travis Hegner.
- */
- if (isset($_SERVER['PATH_INFO']) &&
- $_SERVER['PATH_INFO'] !== substr($_SERVER['SCRIPT_NAME'], - strlen($_SERVER['PATH_INFO'])))
- {
- $url .= $_SERVER['PATH_INFO'];
+ $url = self::getSelfURL();
+ $pos = strpos($url, '?');
+ if (!$pos) {
+ return $url;
}
- return $url;
+ return substr($url, 0, $pos);
}