Permalink
Browse files

bug #28604 [Finder] fixed root directory access for ftp/sftp wrapper …

…(DerDu)

This PR was squashed before being merged into the 3.4 branch (closes #28604).

Discussion
----------

[Finder] fixed root directory access for ftp/sftp wrapper

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27423
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

This fixes a flaw introduced in 3.4.7 by #26763

In order to access the root folder with ftp wrapper, there MUST BE a slash present.
- Currently: from 3.4.7 on it just ```rtrim``` all seperators (```/```, ```\```) from directories
- Now: IF the directory is a (s)ftp:// wrapper (```#^s?ftp://#```) this fix just adds a slash (```/```) again

Commits
-------

9630a38 [Finder] fixed root directory access for ftp/sftp wrapper
  • Loading branch information...
fabpot committed Oct 3, 2018
2 parents 728ab53 + 9630a38 commit 636eb9e55140260ef09e151f94f960d5845a9146
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/Symfony/Component/Finder/Finder.php
@@ -732,12 +732,20 @@ private function searchInDirectory($dir)
/**
* Normalizes given directory names by removing trailing slashes.
*
* Excluding: (s)ftp:// wrapper
*
* @param string $dir
*
* @return string
*/
private function normalizeDir($dir)
{
return rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
$dir = rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
if (preg_match('#^s?ftp://#', $dir)) {
$dir .= '/';
}
return $dir;
}
}

0 comments on commit 636eb9e

Please sign in to comment.