1
0
Fork 0

Merge pull request #1919 from DavidMikeSimon/master

Bugfix: Classmap parsing of PHP source with weird escape-like pattern
pull/1922/head
Jordi Boggiano 2013-05-22 02:24:50 -07:00
commit 978ba292a6
3 changed files with 19 additions and 1 deletions

View File

@ -115,7 +115,7 @@ class ClassMapGenerator
// strip heredocs/nowdocs // strip heredocs/nowdocs
$contents = preg_replace('{<<<\'?(\w+)\'?(?:\r\n|\n|\r)(?:.*?)(?:\r\n|\n|\r)\\1(?=\r\n|\n|\r|;)}s', 'null', $contents); $contents = preg_replace('{<<<\'?(\w+)\'?(?:\r\n|\n|\r)(?:.*?)(?:\r\n|\n|\r)\\1(?=\r\n|\n|\r|;)}s', 'null', $contents);
// strip strings // strip strings
$contents = preg_replace('{"[^"\\\\]*(\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(\\\\.[^\'\\\\]*)*\'}', 'null', $contents); $contents = preg_replace('{"[^"\\\\]*(\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(\\\\.[^\'\\\\]*)*\'}s', 'null', $contents);
// strip leading non-php code if needed // strip leading non-php code if needed
if (substr($contents, 0, 2) !== '<?') { if (substr($contents, 0, 2) !== '<?') {
$contents = preg_replace('{^.+?<\?}s', '<?', $contents); $contents = preg_replace('{^.+?<\?}s', '<?', $contents);

View File

@ -55,6 +55,8 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
'Foo\\LargeGap' => realpath(__DIR__).'/Fixtures/classmap/LargeGap.php', 'Foo\\LargeGap' => realpath(__DIR__).'/Fixtures/classmap/LargeGap.php',
'Foo\\MissingSpace' => realpath(__DIR__).'/Fixtures/classmap/MissingSpace.php', 'Foo\\MissingSpace' => realpath(__DIR__).'/Fixtures/classmap/MissingSpace.php',
'Foo\\StripNoise' => realpath(__DIR__).'/Fixtures/classmap/StripNoise.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', 'Unicode\\↑\\↑' => realpath(__DIR__).'/Fixtures/classmap/Unicode.php',
)), )),
array(__DIR__.'/Fixtures/template', array()), array(__DIR__.'/Fixtures/template', array()),

View File

@ -0,0 +1,16 @@
<?php
namespace Foo;
class SlashedA {
function foo() {
return sprintf("foo\
bar");
}
}
class SlashedB {
function bar() {
print "baz";
}
}