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

bugfix: Restore support for windows machines.

Due to recent changes to fix the way we were building URLs (mixing what the 'baseurlpath' configuration option and the current URL, see #396), we introduced another bug by assuming file paths will always use slashes ('/'), which obviously is not true in Windows machines. This commit fixes SimpleSAML_Configuration::getBaseDir() and SimpleSAML\Utils\HTTP::getSelfURL() to take that into account.

This closes #414.
parent 13cdb400
No related branches found
No related tags found
No related merge requests found
......@@ -595,8 +595,8 @@ class SimpleSAML_Configuration
$dir = $this->getString('basedir', null);
if ($dir !== null) {
// add trailing slash if it is missing
if (substr($dir, -1) !== '/') {
$dir .= '/';
if (substr($dir, -1) !== DIRECTORY_SEPARATOR) {
$dir .= DIRECTORY_SEPARATOR;
}
return $dir;
......@@ -614,8 +614,8 @@ class SimpleSAML_Configuration
$dir = dirname($dir);
// Add trailing slash
$dir .= '/';
// Add trailing directory separator
$dir .= DIRECTORY_SEPARATOR;
return $dir;
}
......
......@@ -724,7 +724,11 @@ class HTTP
$url = self::getBaseURL();
$cfg = \SimpleSAML_Configuration::getInstance();
$baseDir = $cfg->getBaseDir();
$rel_path = str_replace($baseDir.'www/', '', realpath($_SERVER['SCRIPT_FILENAME']));
$rel_path = str_replace(
DIRECTORY_SEPARATOR,
'/',
str_replace($baseDir.'www'.DIRECTORY_SEPARATOR, '', realpath($_SERVER['SCRIPT_FILENAME']))
);
$pos = strpos($_SERVER['REQUEST_URI'], $rel_path) + strlen($rel_path);
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.
Please register or to comment