From d5d8d00ee0c71c28381d2e278157808970996182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Rish=C3=B8j?= Date: Sun, 26 Apr 2020 18:19:25 +0200 Subject: [PATCH] normalize drive letter case --- src/Symfony/Component/Filesystem/Filesystem.php | 8 ++++---- src/Symfony/Component/Filesystem/Tests/FilesystemTest.php | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 12dcb93d4dc90..382b07226a087 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -455,9 +455,9 @@ public function makePathRelative($endPath, $startPath) $startPath = str_replace('\\', '/', $startPath); } - $stripDriveLetter = function ($path) { + $splitDriveLetter = function ($path) { return (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) - ? [substr($path, 2), $path[0]] + ? [substr($path, 2), strtoupper($path[0])] : [$path, null]; }; @@ -475,8 +475,8 @@ public function makePathRelative($endPath, $startPath) return $result; }; - list($endPath, $endDriveLetter) = $stripDriveLetter($endPath); - list($startPath, $startDriveLetter) = $stripDriveLetter($startPath); + list($endPath, $endDriveLetter) = $splitDriveLetter($endPath); + list($startPath, $startDriveLetter) = $splitDriveLetter($startPath); $startPathArr = $splitPath($startPath, static::isAbsolutePath($startPath)); $endPathArr = $splitPath($endPath, static::isAbsolutePath($endPath)); diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 6a55915a3a24e..8ac80437fe5dc 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -1111,6 +1111,7 @@ public function providePathsForMakePathRelative() ['/../aa/bb/cc', '/aa/dd/..', 'bb/cc/'], ['/../../aa/../bb/cc', '/aa/dd/..', '../bb/cc/'], ['C:/aa/bb/cc', 'C:/aa/dd/..', 'bb/cc/'], + ['C:/aa/bb/cc', 'c:/aa/dd/..', 'bb/cc/'], ['c:/aa/../bb/cc', 'c:/aa/dd/..', '../bb/cc/'], ['C:/aa/bb/../../cc', 'C:/aa/../dd/..', 'cc/'], ['C:/../aa/bb/cc', 'C:/aa/dd/..', 'bb/cc/'],