Bug #72688 [NEW]: preg_match missing group names in matches

From: Date: Wed, 27 Jul 2016 15:19:13 +0000
Subject: Bug #72688 [NEW]: preg_match missing group names in matches
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202639@lists.php.net to get a copy of this message
From: konrad dot baumgart at moneyhouse dot de Operating system: Ubuntu 16.04 PHP version: 7.0.9 Package: PCRE related Bug Type: Bug Bug description:preg_match missing group names in matches Description: ------------ When I create many named groups in pattern like \(?'group0'foo)|(?'group1'bar)|…\ then the resulting $matches does not show 'group254'. What was supposed to be in $matches['group254'] is in $matches['group255'], and so on. the lack repeats every ~255 named groups and the offset is getting worse and worse. I tested it on php 7 and php 5.5, locally and in online-php-sandbox. Test script: --------------- <?php $pattern = []; for ($i = 0; $i < 300; $i++) { $pattern[] = "(?'group{$i}'{$i}$)"; } $fullPattern = '/' . implode('|', $pattern) . '/uix'; preg_match($fullPattern, '290', $matches); var_dump(isset($matches['group253'])); var_dump(isset($matches['group254'])); var_dump(isset($matches['group255'])); var_dump($matches['group290']); var_dump($matches['group291']); Expected result: ---------------- bool(true) bool(true) bool(true) string(3) "290" string(0) "" Actual result: -------------- bool(true) bool(false) bool(true) string(0) "" string(3) "290" -- Edit bug report at https://bugs.php.net/bug.php?id=72688&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72688&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72688&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72688&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72688&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72688&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72688&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72688&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72688&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72688&r=support Expected behavior: https://bugs.php.net/fix.php?id=72688&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72688&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72688&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72688&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72688&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72688&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72688&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72688&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72688&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72688&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72688&r=mysqlcfg

« previous php.bugs (#202639) next »