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 ...@@ -595,8 +595,8 @@ class SimpleSAML_Configuration
$dir = $this->getString('basedir', null); $dir = $this->getString('basedir', null);
if ($dir !== null) { if ($dir !== null) {
// add trailing slash if it is missing // add trailing slash if it is missing
if (substr($dir, -1) !== '/') { if (substr($dir, -1) !== DIRECTORY_SEPARATOR) {
$dir .= '/'; $dir .= DIRECTORY_SEPARATOR;
} }
return $dir; return $dir;
...@@ -614,8 +614,8 @@ class SimpleSAML_Configuration ...@@ -614,8 +614,8 @@ class SimpleSAML_Configuration
$dir = dirname($dir); $dir = dirname($dir);
// Add trailing slash // Add trailing directory separator
$dir .= '/'; $dir .= DIRECTORY_SEPARATOR;
return $dir; return $dir;
} }
......
...@@ -724,7 +724,11 @@ class HTTP ...@@ -724,7 +724,11 @@ 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/', '', 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); $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.
Please register or to comment