Bug #80276 [NEW]: (PATTERN_ORDER) Dupl named groups (?J) prefer last alternative even not matched

From: Date: Fri, 23 Oct 2020 14:25:58 +0000
Subject: Bug #80276 [NEW]: (PATTERN_ORDER) Dupl named groups (?J) prefer last alternative even not matched
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229876@lists.php.net to get a copy of this message
From: vicreal at yandex dot ru Operating system: Debian 10 x64 (4.19.132-1) PHP version: 7.4.11 Package: PCRE related Bug Type: Bug Bug description:(PATTERN_ORDER) Dupl named groups (?J) prefer last alternative even not matched Description: ------------ Affect named capture groups when duplicate names are enabled (?J) In 7.4.10 named capture group always returns the content captured in last alternative, no matter which of the alternatives matched. In 7.4 this issue https://bugs.php.net/bug.php?id=79257 was fixed only for PREG_SET_ORDER mode, but in PREG_PATTERN_ORDER mode this bug still has a place. Сhecked in version 7.4.10 Test script: --------------- preg_match_all('/(?J)(?:(?<g>foo)|(?<g>bar))(?<h>baz)/', 'foobaz', $matches, PREG_PATTERN_ORDER); var_dump($matches); Expected result: ---------------- Array ( [0] => Array ( [0] => "foobaz" ) [g] => Array ( [0] => "foo" ) [1] => Array ( [0] => "foo" ) [2] => Array ( [0] => "" ) [h] => Array ( [0] => "baz" ) [3] => Array ( [0] => "baz" ) ) Actual result: -------------- Array ( [0] => Array ( [0] => "foobaz" ) [g] => Array ( [0] => "" ) [1] => Array ( [0] => "foo" ) [2] => Array ( [0] => "" ) [h] => Array ( [0] => "baz" ) [3] => Array ( [0] => "baz" ) ) -- Edit bug report at https://bugs.php.net/bug.php?id=80276&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80276&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80276&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80276&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80276&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80276&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80276&r=support Expected behavior: https://bugs.php.net/fix.php?id=80276&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80276&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80276&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80276&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80276&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80276&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80276&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80276&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80276&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80276&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80276&r=mysqlcfg

« previous php.bugs (#229876) next »