symfony/symfony — pull request #11970 by ymc-dabe (2014-09-20 14:56:03+00:00)
Title: [WIP] [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](a29d1207ced2949c918357cf271200523960caef) checking for this bug
* the [actual fix](9c932f5c6ba443112ca1a278e33e63b45db9b529)

## 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 a29d1207ced2949c918357cf271200523960caef to your symfony clone
2. Run tests

> Result: The new test will fail.