From e1e5eaf6a96f6a24927387c6a8dfcce63378cdc3 Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Sat, 26 Dec 2020 14:33:27 +0100 Subject: [PATCH] Fix Kernel to properly handle Windows paths --- lib/SimpleSAML/Kernel.php | 5 +++-- lib/SimpleSAML/Utils/System.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/SimpleSAML/Kernel.php b/lib/SimpleSAML/Kernel.php index f6d5de3b7..9a51df2c4 100644 --- a/lib/SimpleSAML/Kernel.php +++ b/lib/SimpleSAML/Kernel.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SimpleSAML; +use SimpleSAML\Utils\System; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException; @@ -49,7 +50,7 @@ class Kernel extends BaseKernel $configuration = Configuration::getInstance(); $cachePath = $configuration->getString('tempdir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $this->module; - if (0 === strpos($cachePath, '/')) { + if (System::isAbsolutePath($cachePath)) { return $cachePath; } @@ -65,7 +66,7 @@ class Kernel extends BaseKernel $configuration = Configuration::getInstance(); $loggingPath = $configuration->getString('loggingdir'); - if (0 === strpos($loggingPath, '/')) { + if (System::isAbsolutePath($loggingPath)) { return $loggingPath; } diff --git a/lib/SimpleSAML/Utils/System.php b/lib/SimpleSAML/Utils/System.php index 0a8b837c1..424609710 100644 --- a/lib/SimpleSAML/Utils/System.php +++ b/lib/SimpleSAML/Utils/System.php @@ -226,6 +226,20 @@ class System } } + + /** + * Check if the supplied path is an absolute path. + * + * @param string $path + * + * @return bool + */ + public static function isAbsolutePath(string $path): bool + { + return (0 === strpos($path, '/') || self::pathContainsDriveLetter($path)); + } + + /** * Check if the supplied path contains a Windows-style drive letter. * -- GitLab