diff --git a/lib/SimpleSAML/Kernel.php b/lib/SimpleSAML/Kernel.php index f422eac0726e31b655139fb286d80f2c1540cfb2..e2d72098519bd4b57c1f76bcd3c74f4a17022051 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 374a56326f1cff9b2c5ff45d6d5e354823cce0dd..6997fd04d0b501f59d56ce0f7ebd801018f034d3 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. *