-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Finder] Escape location for regex searches #11970
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
[Finder] Escape location for regex searches #11970
Conversation
If the location to start searching in contains a regex special char like + or ? and the path restriction is a regular expression with a start limitation. No results will be found with at least GnuFindAdapter - e.g.: ``` use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Adapter; mkdir('/tmp/reg+ex/dir/subdir', 0777, true); $finder = Finder::create() ->removeAdapters() ->addAdapter(new Adapter\GnuFindAdapter()); $finder->in('/tmp/reg+ex')->path('/^dir/'); print count($finder)."\n"; ``` Expected result: 2 Actual result is: 0
…th '^' Previously to this commit at least GnuFindAdapter find no result in locations containing regex special chars (e.g. + or ?) and the path restriction is a regular expression with a start limitation (the regex starts with ^).
681aa7b
to
6595b6b
Compare
... as suggested by fabbot.io
Thank you @ymc-dabe. |
This PR was squashed before being merged into the 2.3 branch (closes #11970). Discussion ---------- [Finder] Escape location for regex searches | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - If the location to start searching in contains a regex special char like + or ? and the path restriction is a regular expresion with a start limitation. No results will be found wtih at least GnuFindAdapter - e.g.: ``` use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Adapter; mkdir('/tmp/reg+ex/dir/subdir', 0777, true); $finder = Finder::create() ->removeAdapters() ->addAdapter(new Adapter\GnuFindAdapter()); $finder->in('/tmp/reg+ex')->path('/^dir/'); print count($finder)."\n"; ``` Expected result: 2 Actual result is: 0 This pull request consists of: * a new test checking for this bug (0e81086) * the actual fix (6595b6b) * changes to comply with the coding standard (7f199c5) ## How to reproduce ### Fastest way 1. Move or copy your local symfony clone into a location containing special regex chars: * `mv symfony symfony+regex` 2. Run tests in there * `cd symfony+regex && phpunit` > Result: Some tests in the finder component will fail. ### Alternative: A new clone 1. Clone symfony in a directory containing at least one regex special char * `git clone https://github.com/symfony/symfony.git /tmp/symfony+regexchar` 2. As usual get composer, install dependencies and get phpunit * You might simply want to follow [this guide](http://symfony.com/doc/current/contributing/code/tests.html) 3. Run tests in there * `cd /tmp/symfony+regexchar && phpunit` > Result: Some tests in the finder component will fail. ### Alternative: Apply the new test 1. Apply commit a29d120 to your symfony clone 2. Run tests > Result: The new test will fail. Commits ------- b63926b [Finder] Escape location for regex searches
The tests directory _r+e.g?e_x[c]a(r)s* contains invalid characters in windows so breaks composer install or update because it can't be created. Please revert ASAP and remove that directory name. |
Same issue for me. All windows dev machines are now borked. |
Please revert this ASAP, the pull requests removing the invalid characters aren't passing, but this shouldn't have been commited in the first place. |
Sorry for breaking this for you. It totally forgot about possible limitations in other filesystems/OS here. And thanks @phazei for proposing a fix! |
Closes: symfony#11984 Commit b63926b from PR symfony#11970 introduces a directory containing invalid chars for directory names under windows.
…lder name in test to prevent windows file system issues. (Adam) This PR was merged into the 2.3 branch. Discussion ---------- [Finder][Urgent] Remove asterisk and question mark from folder name in test to prevent windows file system issues. Bugfix: Yes Fixed tickets: #11984 , #11985 Related tickets: #11970 Commit #11970 prevented Symphony from being checked out via windows due to invalid characters in a folder name within the tests. The issue was reported in #11984 and was attempted to be fixed in #11985 but wasn't due to still including the question mark. Please accept this ASAP as it entirely breaks any composer that relies on it. Commits ------- 5fbb278 Avoid question mark and asterisk in folder names to prevent windows filesystem issues.
If the location to start searching in contains a regex special char
like + or ? and the path restriction is a regular expresion with a start
limitation. No results will be found wtih at least GnuFindAdapter - e.g.:
Expected result: 2
Actual result is: 0
This pull request consists of:
How to reproduce
Fastest way
mv symfony symfony+regex
cd symfony+regex && phpunit
Alternative: A new clone
git clone https://github.com/symfony/symfony.git /tmp/symfony+regexchar
cd /tmp/symfony+regexchar && phpunit
Alternative: Apply the new test