From 9e431038b204c6ebe53b2d628c0df52df086bd4a Mon Sep 17 00:00:00 2001 From: Christopher Hertel Date: Wed, 12 Feb 2020 22:21:47 +0100 Subject: [PATCH] fix unix root dir issue --- src/Symfony/Component/Finder/Finder.php | 4 ++++ .../Finder/Iterator/RecursiveDirectoryIterator.php | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index d2ea17d87a..33a76cc976 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -744,6 +744,10 @@ class Finder implements \IteratorAggregate, \Countable */ private function normalizeDir($dir) { + if ('/' === $dir) { + return $dir; + } + $dir = rtrim($dir, '/'.\DIRECTORY_SEPARATOR); if (preg_match('#^(ssh2\.)?s?ftp://#', $dir)) { diff --git a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php index ab48a2b8a1..63764d407d 100644 --- a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php +++ b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php @@ -74,7 +74,11 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator } $subPathname .= $this->getFilename(); - return new SplFileInfo($this->rootPath.$this->directorySeparator.$subPathname, $this->subPath, $subPathname); + if ('/' !== $basePath = $this->rootPath) { + $basePath .= $this->directorySeparator; + } + + return new SplFileInfo($basePath.$subPathname, $this->subPath, $subPathname); } /**