Bug #69309 [NEW]: preg_replace return NULL on certain string

From: 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

« previous php.bugs (#191621) next »