From e58285d9b57d1cf5c79e18d569302f04b04eb121 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 f422eac07..e2d720985 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; @@ -51,7 +52,7 @@ class Kernel extends BaseKernel $configuration = Configuration::getInstance(); $cachePath = $configuration->getString('tempdir') . '/cache/' . $this->module; - if (0 === strpos($cachePath, '/')) { + if (System::isAbsolutePath($cachePath)) { return $cachePath; } @@ -67,7 +68,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 374a56326..6997fd04d 100644 --- a/lib/SimpleSAML/Utils/System.php +++ b/lib/SimpleSAML/Utils/System.php @@ -238,6 +238,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