Bug #69309 [NEW]: preg_replace return NULL on certain string
| From: | dodothedreamer at gmail dot com | Date: | Thu, 26 Mar 2015 14:21:41 +0000 |
| Subject: | Bug #69309 [NEW]: preg_replace return NULL on certain string | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-191621@lists.php.net to get a copy of this message | ||
From: dodothedreamer at gmail dot com
Operating system: Ubuntu
PHP version: 5.4.39
Package: *Regular Expressions
Bug Type: Bug
Bug description:preg_replace return NULL on certain string
Description:
------------
I saw this bug on PHP version 5.4.32 and also on 5.5.9-1ubuntu4.7
When you enter a certain string ( see the test script) to preg_replace,
it returns NULL. Some small changes in the string don't cause this
error, for example if you delete one of the "a" characters from the end,
then the bug doesn't happen.
preg_last_error() return 2.
Increasing pcre.backtrack_limit and pcre.recursion_limit does not help (
the regex engine seems to get stuck in a loop for a long time )
Test script:
---------------
$returnValue = preg_replace('#\\<figure +.*?\\>\\<img
+(.+?)/\\>.*?\\<figcaption\\>\\<a
href="(.+?)".*?\\>(.*?)\\</a\\>\\</figcaption\\>.*?\\</figure\\>#s',
'<figure class="caption"><a href="$2"><img $1/></a>
<figcaption><a
href="$2">$3</a></figcaption> </figure>', '<figure
class="caption"
style="float:left"><img alt="×ת×××
××§× ××××× ×××¢×× ×
×××××× ×× ×¢× ×××¡× ×××× "
onmouseup="this.src="graphic/img1530.jpg"" src="img1530.jpg" />
<figcaption><a
href="http://tivonim-blog.co.il/%D7%A7%D7%A0%D7%99%D7%99%D7%93%D7%9C%D7%9A-%D7%98%D7%91%D7%A2%D7%95%D7%A0%D7%99-%D7%9E%D7%95%D7%A9%D7%9C%D7%9D-%D7%9E%D7%A8%D7%A7/">×ת×××
××§× ××××× ×××¢×× × </a>××××××
"×× ×¢× ××ס×
××××"Â </figcaption>
</figure>
<p>×× ×ת ר×ש×× ×ת, ס××××
×ת×ספ×ת:</p>
<p><strong style="font-size: 10pt;"><a
href="art160.html">ס××
פ×פ××× ×§×××××</a></strong></p>
<p><strong style="font-size: 10pt;"><a
href="art161.html">ס×× ×ס×,
ס××¨× ×××××× ×××</a></strong></p>
<p><strong style="font-size: 10pt;"><a
href="art162.html">ס××
ס××§</a></strong></p>
<p><strong style="font-size: 10pt;"><a
href="art198.html">×ספר××ס
×ש××פ×× ×שק×××</a></strong></p>
<p><span style="font-size: 10pt;">×רק××:</span></p>
<p><strong style="font-size: 10pt;"><a
href="http://veg.anonymous.org.il/art283.html">×רק
×§××× ×××</a></strong></p>
<p><strong style="font-size: 10pt;"><a
href="art178.html">×רק
×צ×</a></strong></p>
<p><span style="font-size: 10pt;">×× ×ת
×¢×קר××ת:</span></p>
<p><strong style="font-size: 10pt;"><a
href="http://veg.anonymous.org.il/art552.html">ת×ת××ת
×ר××ש××§ ××××××ת
×§×× ×××</a></strong></p>
<p><strong style="font-size: 10pt;"><a
href="http://veg.anonymous.org.il/art627.html">פ×ר××ת
××××××ת ×קר×
××××××</a></strong></p>
<p><a href="http://veg.anonymous.org.il/art347.html"
style="font-size:
10pt;"><b>×§×× ××× ×עש××
ת××××</b></a></p>
<p><strong style="font-size: 10pt;"><a
href="art229.html">תפ××-×××× ××קר×
×××× ×§××§×ס
×תר×</a></strong></p>
<p><span style="font-size:
10pt;">×§×× ××××:</span></p>
aaaaaaaaaa
');
--
Edit bug report at https://bugs.php.net/bug.php?id=69309&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69309&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69309&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69309&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69309&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69309&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69309&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69309&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69309&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69309&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69309&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69309&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69309&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69309&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69309&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69309&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69309&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69309&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69309&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69309&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69309&r=mysqlcfg