From 209cc5f279e5615bd518e5320a83fd5fd5ec29de Mon Sep 17 00:00:00 2001 From: Steve Talbot Date: Mon, 6 Jul 2020 13:39:17 +0100 Subject: [PATCH 1/2] Fixed bug #3007: Directory exclude pattern improperly excludes directories with names that start the same --- src/Filters/Filter.php | 2 +- tests/Core/Filters/Filter/AcceptTest.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Filters/Filter.php b/src/Filters/Filter.php index fa7360f0cd..cc809f7afe 100644 --- a/src/Filters/Filter.php +++ b/src/Filters/Filter.php @@ -218,7 +218,7 @@ protected function shouldIgnorePath($path) // Need to check this pattern for dirs as well as individual file paths. $this->ignoreFilePatterns[$pattern] = $type; - $pattern = substr($pattern, 0, -2); + $pattern = substr($pattern, 0, -2) . '(?=/|$)'; $this->ignoreDirPatterns[$pattern] = $type; } else { // This is a file-specific pattern, so only need to check this diff --git a/tests/Core/Filters/Filter/AcceptTest.php b/tests/Core/Filters/Filter/AcceptTest.php index 5d928c38b8..2c9f57cd39 100644 --- a/tests/Core/Filters/Filter/AcceptTest.php +++ b/tests/Core/Filters/Filter/AcceptTest.php @@ -111,9 +111,13 @@ public function dataExcludePatterns() '/path/to/src/Main.php', '/path/to/src/Something/Main.php', '/path/to/src/Somethingelse/Main.php', + '/path/to/src/SomethingelseEvenLonger/Main.php', '/path/to/src/Other/Main.php', ], - ['/path/to/src/Main.php'], + [ + '/path/to/src/Main.php', + '/path/to/src/SomethingelseEvenLonger/Main.php', + ], ], // Test ignoring standard/sniff specific exclude patterns. From 367c60cb925c2741e67e3428019ff39268975cae Mon Sep 17 00:00:00 2001 From: Steve Talbot Date: Mon, 6 Jul 2020 14:25:55 +0100 Subject: [PATCH 2/2] Remove spaces around concat operator #3007 --- src/Filters/Filter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Filters/Filter.php b/src/Filters/Filter.php index cc809f7afe..5bed499b25 100644 --- a/src/Filters/Filter.php +++ b/src/Filters/Filter.php @@ -218,7 +218,7 @@ protected function shouldIgnorePath($path) // Need to check this pattern for dirs as well as individual file paths. $this->ignoreFilePatterns[$pattern] = $type; - $pattern = substr($pattern, 0, -2) . '(?=/|$)'; + $pattern = substr($pattern, 0, -2).'(?=/|$)'; $this->ignoreDirPatterns[$pattern] = $type; } else { // This is a file-specific pattern, so only need to check this