Skip to content

[Finder] Remove duplicate slashes in filenames #26763

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

Merged
merged 1 commit into from
Apr 4, 2018
Merged

Conversation

helhum
Copy link
Contributor

@helhum helhum commented Apr 3, 2018

Q A
Branch? 2.7 up to 4.0
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #26757
License MIT

This PR takes another approach to fix in excess slashes in Finder than #26337
which does a simple rtrim instead of the breaking realpath.

@keradus
Copy link
Member

keradus commented Apr 3, 2018

original change was targetting 2.7, this branch is targetting master=4.1, please adjust target branch

@@ -540,9 +540,9 @@ public function in($dirs)

foreach ((array) $dirs as $dir) {
if (is_dir($dir)) {
$resolvedDirs[] = $dir;
$resolvedDirs[] = rtrim($dir, '/\\');
Copy link
Member

@nicolas-grekas nicolas-grekas Apr 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be rtrim($dir, '/'.\DIRECTORY_SEPARATOR); (same below)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\DIRECTORY_SEPARATOR can be '/' or '\'

'/'.\DIRECTORY_SEPARATOR would be literal // on *nix systems.

I can change that of course, just asking myself what the benefit would be

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the benefit would be that on *nix, \ should not be trimmed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, thanks.

@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Apr 3, 2018
@keradus
Copy link
Member

keradus commented Apr 3, 2018

please add missing test that were not present in original PR, that caused integrated project to fail. (eg one with /foo/../bar/baz normalization and symlink

@helhum
Copy link
Contributor Author

helhum commented Apr 3, 2018

original change was targetting 2.7, this branch is targetting master=4.1, please adjust target branch

Does this mean, the PR should be based on 2.7 branch?

@nicolas-grekas
Copy link
Member

Does this mean, the PR should be based on 2.7 branch?

correct

@helhum helhum changed the base branch from master to 2.7 April 3, 2018 11:20
@helhum helhum force-pushed the fix-finder branch 2 times, most recently from c65b064 to a7007e9 Compare April 3, 2018 11:29
@helhum
Copy link
Contributor Author

helhum commented Apr 3, 2018

Working on tests for symlinked dirs now

@helhum
Copy link
Contributor Author

helhum commented Apr 3, 2018

Finder tests should pass now. Let me know if I can do anything else

@@ -26,55 +26,80 @@ public function testDirectories()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->directories());
$this->assertIterator($this->toAbsolute(array('foo', 'toto')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator(self::toAbsolute(array('foo', 'toto')), $finder->in(self::$tmpDir)->getIterator());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert all these changes, they are unrelated to the PR and make reviewing harder than strictly required

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, sorry. Should be fixed, but of course is unrelated to this change

@helhum
Copy link
Contributor Author

helhum commented Apr 3, 2018

This comment might give more explanation why I changed the code like that.

@fabpot
Copy link
Member

fabpot commented Apr 4, 2018

Thank you @helhum.

@fabpot fabpot merged commit cdde6d9 into symfony:2.7 Apr 4, 2018
fabpot added a commit that referenced this pull request Apr 4, 2018
This PR was squashed before being merged into the 2.7 branch (closes #26763).

Discussion
----------

[Finder] Remove duplicate slashes in filenames

| Q             | A
| ------------- | ---
| Branch?       | 2.7 up to 4.0
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #26757
| License       | MIT

This PR takes another approach to fix in excess slashes in Finder than #26337
which does a simple rtrim instead of the breaking realpath.

Commits
-------

cdde6d9 [Finder] Remove duplicate slashes in filenames
@DanielRuf
Copy link

Are there changes needed in the testsuite?

@helhum
Copy link
Contributor Author

helhum commented Apr 4, 2018

@DanielRuf What do you mean? I changed and added tests within this PR. Anything else you think needs to be done?

@xabbuh
Copy link
Member

xabbuh commented Apr 4, 2018

see #26785

@DanielRuf
Copy link

@DanielRuf What do you mean? I changed and added tests within this PR. Anything else you think needs to be done?

I still see some failing tests at Travis
https://travis-ci.org/symfony/symfony/builds/361968716
https://travis-ci.org/symfony/symfony/builds/361968670

@DanielRuf
Copy link

see #26785

Great, exactly what I've meant =)

@bobdenotter
Copy link
Contributor

Thanks! This (and the bump to symfony/finder) resolved the issues Bolt users were seeing.

fabpot added a commit that referenced this pull request 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

Successfully merging this pull request may close these issues.

8 participants