Skip to content
Snippets Groups Projects
Commit c72b6203 authored by Jaime Pérez's avatar Jaime Pérez
Browse files

bugfix: Resolve issue with incorrect self URL when using symlinks.

Recent commits have introduced a new way to obtain the self URL, honouring whatever is specified in 'baseurlpath'. However, this new code breaks when accessing SimpleSAMLphp through a path containing symbolic links in the file system, since the base directory refers always to the real path while the $_SERVER contents reflect what the web server sees (symlinks included). We use realpath() to convert a path with symlinks to a canonical path that we can compare.
parent 9ff8b6f7
No related branches found
No related tags found
No related merge requests found
...@@ -722,7 +722,7 @@ class HTTP ...@@ -722,7 +722,7 @@ class HTTP
$url = self::getBaseURL(); $url = self::getBaseURL();
$cfg = \SimpleSAML_Configuration::getInstance(); $cfg = \SimpleSAML_Configuration::getInstance();
$baseDir = $cfg->getBaseDir(); $baseDir = $cfg->getBaseDir();
$rel_path = str_replace($baseDir.'www/', '', $_SERVER['SCRIPT_FILENAME']); $rel_path = str_replace($baseDir.'www/', '', realpath($_SERVER['SCRIPT_FILENAME']));
$pos = strpos($_SERVER['REQUEST_URI'], $rel_path) + strlen($rel_path); $pos = strpos($_SERVER['REQUEST_URI'], $rel_path) + strlen($rel_path);
return $url.$rel_path.substr($_SERVER['REQUEST_URI'], $pos); return $url.$rel_path.substr($_SERVER['REQUEST_URI'], $pos);
} }
......
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