From 2665c60b2f03fe8069b1825bbe33e772367f518b Mon Sep 17 00:00:00 2001 From: David Simon Date: Tue, 21 May 2013 16:29:11 -0400 Subject: [PATCH 1/2] Test for bug parsing multiline strings with 'escaped' newlines --- .../Test/Autoload/ClassMapGeneratorTest.php | 2 ++ .../classmap/BackslashLineEndingString.php | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/Composer/Test/Autoload/Fixtures/classmap/BackslashLineEndingString.php diff --git a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php index 40d79849c..ddadc89c5 100644 --- a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php +++ b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php @@ -55,6 +55,8 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase 'Foo\\LargeGap' => realpath(__DIR__).'/Fixtures/classmap/LargeGap.php', 'Foo\\MissingSpace' => realpath(__DIR__).'/Fixtures/classmap/MissingSpace.php', 'Foo\\StripNoise' => realpath(__DIR__).'/Fixtures/classmap/StripNoise.php', + 'Foo\\SlashedA' => realpath(__DIR__).'/Fixtures/classmap/BackslashLineEndingString.php', + 'Foo\\SlashedB' => realpath(__DIR__).'/Fixtures/classmap/BackslashLineEndingString.php', 'Unicode\\↑\\↑' => realpath(__DIR__).'/Fixtures/classmap/Unicode.php', )), array(__DIR__.'/Fixtures/template', array()), diff --git a/tests/Composer/Test/Autoload/Fixtures/classmap/BackslashLineEndingString.php b/tests/Composer/Test/Autoload/Fixtures/classmap/BackslashLineEndingString.php new file mode 100644 index 000000000..6c8b94c9b --- /dev/null +++ b/tests/Composer/Test/Autoload/Fixtures/classmap/BackslashLineEndingString.php @@ -0,0 +1,16 @@ + Date: Tue, 21 May 2013 16:29:25 -0400 Subject: [PATCH 2/2] Fixed bug parsing multiline strings with 'escaped' newlines --- src/Composer/Autoload/ClassMapGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Autoload/ClassMapGenerator.php b/src/Composer/Autoload/ClassMapGenerator.php index cb8a548f2..c291f4eef 100644 --- a/src/Composer/Autoload/ClassMapGenerator.php +++ b/src/Composer/Autoload/ClassMapGenerator.php @@ -115,7 +115,7 @@ class ClassMapGenerator // strip heredocs/nowdocs $contents = preg_replace('{<<<\'?(\w+)\'?(?:\r\n|\n|\r)(?:.*?)(?:\r\n|\n|\r)\\1(?=\r\n|\n|\r|;)}s', 'null', $contents); // strip strings - $contents = preg_replace('{"[^"\\\\]*(\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(\\\\.[^\'\\\\]*)*\'}', 'null', $contents); + $contents = preg_replace('{"[^"\\\\]*(\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(\\\\.[^\'\\\\]*)*\'}s', 'null', $contents); // strip leading non-php code if needed if (substr($contents, 0, 2) !== '