8000 [Finder] removed trailing slashes lead to error when listing files in FTP root dir · Issue #27423 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Finder] removed trailing slashes lead to error when listing files in FTP root dir #27423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jfmaeck opened this issue May 30, 2018 · 1 comment

Comments

@jfmaeck
Copy link
jfmaeck commented May 30, 2018

Symfony version(s) affected: 4.0.11 (might as well be earlier versions)

Description
In Finder 4.0.8 the commit symfony/finder@45429ad was released which should remove duplicate slashes from path names.

However, this results in an error when used to find files in an FTP root dir.
The documentation (https://symfony.com/doc/current/components/finder.html:) by the way explicitly states that the slash is required in this case:

// always add a trailing slash when looking for in the FTP root dir
$finder->in('ftp://example.com/');

How to reproduce

        $finder = new Finder();
        $files = $finder->files()->in('ftp://speedtest.tele2.net/');
        foreach ($files as $file) {
            var_dump($file);
        }

Possible Solution
One might parse the given $dirstring and trwat it differently if ti starts with "ftp://"

@tristanbes
Copy link
Contributor
tristanbes commented Jun 19, 2018

Hello,

This seems like a BC break for a ftp:// stream for example. One of our cont 9FE0 ractor encountered this problem too when upgrading a minor version.

Though I personnally recommand to use Flysystem or Gaufrette to connect to distant filesystems, this should be either fixed, or either mentionned in the documentation that it's no longer possible to do that.

Because right now, as pointed out by @jfmaeck, even the documentation says that a trailing slash must be added

the_finder_component__symfony_docs_

And since #26337, the trailing slash is removed.

As a result, a working code before v3.4.7 result in breaking code after v3.4.7

ping @lyrixx which was the author of the initial PR to have his point of view. Also interested in Symfony core point of view on this problem @stof

@fabpot fabpot closed this as completed Oct 3, 2018
fabpot added a commit that referenced this issue Oct 3, 2018
…(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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0