Bug #11649 [Com]: New Code regex fails
| From: | mreschke | Date: | Thu, 28 Oct 2010 22:09:59 +0000 |
| Subject: | Bug #11649 [Com]: New Code regex fails | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-4997@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=11649&edit=1
ID: 11649
Comment by: mreschke
Reported By: mail at mreschke dot com
Summary: New Code regex fails
Status: Open
Type: Bug
Package: Text_Wiki
Package Version: 1.2.0
PHP Version: Irrelevant
New Comment:
Have had this problem for years. Large < code > snippets crashed, just
blank white page, no php errors or anything. Thought it might have been
the php.ini pcre.backtrack/recursion limits but no. Thanks for the
patch, all I did was replace the $regex in Parser/Default/code.php with
this one
var $regex = ';<code(\s[^>]*)?>\n?((?:[^<]*(?R)?.*?)*?)</code>;msi';
Now I can have virtually unlimited < code >, thanks.
Previous Comments:
------------------------------------------------------------------------
[2009-10-08 17:54:26] yunosh
There is a test case: http://wiki.horde.org/TurbaOutlook2003
Grab the source and pass it through the default Text_Wiki
parser/renderer.
------------------------------------------------------------------------
[2009-10-08 15:54:21] doconnor
Am inclined to wontfix this without a testcase, due to 'there is
something wrong with your php' comments (if there's a test case I'm
missing it) :S
------------------------------------------------------------------------
[2008-11-29 07:40:07] yunosh
Sounds like pcre.backtrack_limit that has been introduced with PHP 5.2.0
with a too small default value.
------------------------------------------------------------------------
[2008-11-29 07:04:05] ifeghali
I did one more test with PHP 4.4.8 and it failed at 1000 chars.
------------------------------------------------------------------------
[2008-11-29 06:54:28] ifeghali
Running a modified version of Nicola's code:
<?php
$regex = ';^<code(\s[^>]*)?>((?:(?R)|.*?)*)\n</code>(\s|$);msi';
for ($i = 900;; $i += 100)
{
$text = '<code>' . str_repeat('x', $i) . "\n</code>";
$result = preg_replace($regex, 'It worked', $text);
print "$i: ";
var_dump($result);
}?>
on PHP 5.2.6 gives me the result:
900: string(9) "It worked"
1000: string(9) "It worked"
1100: string(9) "It worked"
1200: string(9) "It worked"
1300: string(9) "It worked"
1400: string(9) "It worked"
1500: string(9) "It worked"
1600: string(9) "It worked"
1700: string(9) "It worked"
1800: string(9) "It worked"
1900: string(9) "It worked"
2000: string(9) "It worked"
2100: string(9) "It worked"
2200: string(9) "It worked"
2300: string(9) "It worked"
2400: string(9) "It worked"
2500: string(9) "It worked"
2600: string(9) "It worked"
2700: string(9) "It worked"
2800: string(9) "It worked"
2900: string(9) "It worked"
3000: string(9) "It worked"
Segmentation fault
on PHP 5.2.5, exactly same machine:
900: string(9) "It worked"
1000: string(9) "It worked"
1100: string(9) "It worked"
1200: string(9) "It worked"
1300: string(9) "It worked"
1400: string(9) "It worked"
1500: string(9) "It worked"
1600: string(9) "It worked"
Segmentation fault
So it seems that its something up to the PHP version you are running.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://pear.php.net/bugs/bug.php?id=11649
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=11649&edit=1