From 93793d935e584fe2075dcf9984661f9915547ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Pe=CC=81rez?= <jaime.perez@uninett.no> Date: Tue, 5 Jul 2016 12:21:54 +0200 Subject: [PATCH] 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. --- lib/SimpleSAML/Configuration.php | 8 ++++---- lib/SimpleSAML/Utils/HTTP.php | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php index b5ce246ef..088b662f7 100644 --- a/lib/SimpleSAML/Configuration.php +++ b/lib/SimpleSAML/Configuration.php @@ -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; } diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php index 612bf5c42..de6149f39 100644 --- a/lib/SimpleSAML/Utils/HTTP.php +++ b/lib/SimpleSAML/Utils/HTTP.php @@ -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); } -- GitLab