Skip to content

Instantly share code, notes, and snippets.

@pbull
Last active August 29, 2015 14:08
Show Gist options
  • Save pbull/b04f1ac473650ddf95a6 to your computer and use it in GitHub Desktop.
Save pbull/b04f1ac473650ddf95a6 to your computer and use it in GitHub Desktop.
This code will segfault php 5.5 (for testing/debugging purposes)
<?php
$contents = '/*' . str_repeat('a', 60000) . '*/ Test1';
$contents = preg_replace('<
\s*([@{}:;,]|\)\s|\s\()\s* | # Remove whitespace around separators, but keep space around parentheses.
/\*([^*\\\\]|\*(?!/))+\*/ | # Remove comments that are not CSS hacks.
[\n\r] # Remove line breaks.
>x', '\1', $contents);
print $contents;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment