From 4d74f5ba957468afe124849ceaf38c2fcf5b871a Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 12 Feb 2020 10:23:03 +0100 Subject: [PATCH] Fix exclude-from-classmap handling to avoid foo matching foo* directories, fixes #8563, refs #8575 --- src/Composer/Autoload/AutoloadGenerator.php | 2 +- tests/Composer/Test/Autoload/AutoloadGeneratorTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 940ab3f18..2bb0c98b1 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -901,7 +901,7 @@ INITIALIZER; } $resolvedPath = realpath($installPath . '/' . $updir); - $autoloads[] = preg_quote(strtr($resolvedPath, '\\', '/')) . '/' . $path; + $autoloads[] = preg_quote(strtr($resolvedPath, '\\', '/')) . '/' . $path . '($|/)'; continue; } diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index ff81581d7..055b03e1c 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -1525,8 +1525,8 @@ EOF; '/composersrc/ClassToExclude.php', '/composersrc/*/excluded/excsubpath', '**/excsubpath', - 'composers', // should _not_ cause exclusion of /composersrc/** - '/src-ca/', // should _not_ cause exclusion of /src-cake/** + 'composers', // should _not_ cause exclusion of /composersrc/**, as it is equivalent to /composers/** + '/src-ca/', // should _not_ cause exclusion of /src-cake/**, as it is equivalent to /src-ca/** ), ));