Skip to content

Instantly share code, notes, and snippets.

/runme.php Secret

Created January 6, 2013 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7f465d4109d667a73984 to your computer and use it in GitHub Desktop.
Save anonymous/7f465d4109d667a73984 to your computer and use it in GitHub Desktop.
PHP 5.5 Segfault
<?php
class Test
{
public static function a($path)
{
$contents = php_strip_whitespace($path);
var_dump('content:');
var_dump($contents);
var_dump('test');
var_dump(preg_replace('{.*}s', 'a', $contents));
var_dump('starting');
$contents = preg_replace('{<<<\'?(\w+)\'?(?:\r\n|\n|\r)(?:.*?)(?:\r\n|\n|\r)\\1(?=\r\n|\n|\r|;)}s', 'null', $contents);
$contents = preg_replace('{"[^"\\\\]*(\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(\\\\.[^\'\\\\]*)*\'}', 'null', $contents);
var_dump('done');
return $contents;
}
}
var_dump(Test::a(__DIR__.'/testcase.php') === "<?php\n namespace Foo; class StripNoise { public function test() { return null\n; } } ");
<?php
namespace Foo;
/**
* class Fail { }
*/
class StripNoise
{
public function test()
{
return <<<A
class Fail23
{
}
A
;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment