diff --git a/src/Internal/Util/PathMatcher.php b/src/Internal/Util/PathMatcher.php index 7a0b2d1..b06f39c 100644 --- a/src/Internal/Util/PathMatcher.php +++ b/src/Internal/Util/PathMatcher.php @@ -290,7 +290,10 @@ public static function mayPathBeIncluded(string $normalizedPath): bool } } - if (str_contains($canon, '/var/') || str_starts_with($canon, 'var/')) { + if (str_starts_with($canon, 'var/') + || (!str_starts_with($canon, '/var/') && str_contains($canon, '/var/')) + || (str_starts_with($canon, '/var/') && str_contains(substr($canon, 4), '/var/')) + ) { if (! self::hasIncludeMatchingPrefix('var/', $includes)) { return false; } diff --git a/tests/Internal/Util/PathMatcherTest.php b/tests/Internal/Util/PathMatcherTest.php index ab49b93..130c9be 100644 --- a/tests/Internal/Util/PathMatcherTest.php +++ b/tests/Internal/Util/PathMatcherTest.php @@ -250,6 +250,18 @@ } }); + test('permits var when var is root directory using default config', function () { + try { + Config::set([ + 'include' => ['src/**', 'app/**', 'tests/**',], + ]); + + expect(PathMatcher::mayPathBeIncluded('/var/www/app/src/index.php'))->toBeTrue(); + } finally { + Config::reset(); + } + }); + test('permits vendor, var, or storage paths when explicitly whitelisted in include config', function () { try { Config::set([