From: jille at hexon dot cx Operating system: n/a PHP version: 5.4.7 Package: PCRE related Bug Type: Bug Bug description:Recursion and greedy
Description: ------------ See test-script. When I make the recursive-backreference (?R) optional (with ?) it doesn't match $str to its full extent. Test script: --------------- <?php $str = "A{X|param:{Y}}B"; $reWanted = '/{[A-Z]+(\|param:[^|}]*(?R)?[^|}]*)*}/'; var_dump(preg_match($reWanted, $str, $m), $m); $reWorking = '/{[A-Z]+(\|param:[^|}]*(?R)[^|}]*)*}/'; var_dump(preg_match($reWorking, $str, $m), $m); $reWorking2 = '/{[A-Z]+(\|param:([^|}]*(?R)[^|}]*|[^|}]*))*}/'; var_dump(preg_match($reWorking2, $str, $m), $m); ?> Expected result: ---------------- For all three cases: int(1) array(3) { [0]=> string(13) "{X|param:{Y}}" [1]=> string(10) "|param:{Y}" [2]=> string(3) "{Y}" } Actual result: -------------- Using $reWanted gives this instead of the expected result. Note the missing } int(1) array(2) { [0]=> string(12) "{X|param:{Y}" [1]=> string(9) "|param:{Y" } -- Edit bug report at https://bugs.php.net/bug.php?id=63218&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63218&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63218&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63218&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63218&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63218&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63218&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63218&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63218&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=63218&r=support Expected behavior: https://bugs.php.net/fix.php?id=63218&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63218&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63218&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63218&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63218&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63218&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63218&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=63218&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63218&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63218&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63218&r=mysqlcfg