Skip to content

[Finder] Destroys file names with whitespaces #5851

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
Rayne opened this issue Oct 28, 2012 · 3 comments · Fixed by #5859
Closed

[Finder] Destroys file names with whitespaces #5851

Rayne opened this issue Oct 28, 2012 · 3 comments · Fixed by #5859

Comments

@Rayne
Copy link

Rayne commented Oct 28, 2012

When I am using Finder correct, it destroys file names containing whitespaces when using built-in sorting features (for instance Finder::sortByType()). Sorting with Closures works as expected.

Example: /a/b c will be cut to /a/b.

OS: ArchLinux, Linux 3.5.4-1-ARCH
FS: EXT4
PHP: 5.4.7 (cli)
Finder: 2.2-dev

Test: https://gist.github.com/ec2bb92a2c65133187c8

1) Test::testWithBuiltInSorting with data set #0 ('/tmp/finder-test/2012-10-28T15:27:41+01:00', '/tmp/finder-test/2012-10-28T15:27:41+01:00/HELLO WHITESPACE!')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'/tmp/finder-test/2012-10-28T15:27:41+01:00/HELLO WHITESPACE!'
+'/tmp/finder-test/2012-10-28T15:27:41+01:00/HELLO'
@stof
Copy link
Member

stof commented Oct 28, 2012

@jfsimon ping

@jfsimon
Copy link
Contributor

jfsimon commented Oct 28, 2012

This is due to the use of awk command here: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php#L309

I'll try to find time to write a test and fix the bug quickly.

@Rayne
Copy link
Author

Rayne commented Oct 28, 2012

Thank you for the answer. I will use this as workaround for now:

use Symfony\Component\Finder\Adapter\PhpAdapter;
…
$finder->removeAdapters();
$finder->addAdapter(new PhpAdapter());

fabpot added a commit that referenced this issue Oct 29, 2012
This PR was merged into the master branch.

Commits
-------

2817a47 [Finder] Fixed filename containing space bug in gnu adapter.
9bf7cb0 [Finder] Added filename containing space to tests.

Discussion
----------

[Finder] Fixed filename containing space bug in gnu find adapter.

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes: #5851

`GNU find` adapter now uses `cut` instead of `awk`.
@fabpot fabpot closed this as completed Oct 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants