From: Operating system: Windows Vista PHP version: 5.4.3 Package: PCRE related Bug Type: Bug Bug description:Fails when recursive group comes before reference
Description: ------------ When the recursive subpattern is captured after it is referenced: (?2)?::(?>((?1)(?>:(?1)){0,4}):)? It works fine. But when the capture comes before the reference it doesn't: ((?1)(?>:(?1)){0,4})?::(?>(?2):)? The problem is the final ":" as other characters work fine. Replacing it with "\:" or "[:]" does not help. Test script: --------------- // Test 1 preg_match('/^(?>([a-f0-9]{1,4})(?>:(?1)){5}:|(?!(?:.*[a-f0-9]:){6,})(?2)?::(?>((?1)(?>:(?1)){0,4}):)?)(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?3)){3}$/iD', '0:0:0:0::0:255.255.255.255'); // Test 2 preg_match('/^(?>([a-f0-9]{1,4})(?>:(?1)){5}:|(?!(?:.*[a-f0-9]:){6,})((?1)(?>:(?1)){0,4})?::(?>(?2):)?)(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?3)){3}$/iD', '0:0:0:0::0:255.255.255.255'); // Test 3 preg_match('/^(?>([a-f0-9]{1,4})(?>:(?1)){5}:|(?!(?:.*[a-f0-9]:){6,})((?1)(?>:(?1)){0,4})?::(?>(?2)!)?)(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?3)){3}$/iD', '0:0:0:0::0!255.255.255.255'); Expected result: ---------------- // Test 1 int(1) // Test 2 int(1) // Test 3 int(1) Actual result: -------------- // Test 1 int(1) // Test 2 int(0) // Test 3 int(1) -- Edit bug report at https://bugs.php.net/bug.php?id=62041&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62041&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62041&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62041&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=62041&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62041&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=62041&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=62041&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=62041&r=needscript Try newer version: https://bugs.php.net/fix.php?id=62041&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=62041&r=support Expected behavior: https://bugs.php.net/fix.php?id=62041&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=62041&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=62041&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=62041&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62041&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=62041&r=dst IIS Stability: https://bugs.php.net/fix.php?id=62041&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=62041&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=62041&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=62041&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=62041&r=mysqlcfg