diff --git a/lib/SimpleSAML/Kernel.php b/lib/SimpleSAML/Kernel.php index f6d5de3b7f3af73ad0598766160d964614dab211..9a51df2c46e6477aebd1bb151453fd92bc07cfef 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 0a8b837c10b1ff8753bb6c5a0c01f997a1055fae..424609710f69602b89e87379c3465682e20b924a 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. *