Bug #81101 [NEW]: PCRE2 10.37 shows unexpected result

From: Date: Thu, 03 Jun 2021 14:19:56 +0000
Subject: Bug #81101 [NEW]: PCRE2 10.37 shows unexpected result
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234186@lists.php.net to get a copy of this message
From:             rlanting at move4mobile dot com
Operating system: MacOS 11.3.1
PHP version:      8.0.6
Package:          PCRE related
Bug Type:         Bug
Bug description:PCRE2 10.37 shows unexpected result

Description:
------------
This week I updated php and pcre through homebrew. As a result I got
pcre2 10.37. For that specific version preg_match doesn't work as
expected. Reverting only pcre2 to 10.36 makes it work again.

The regex originates from
https://github.com/phpspec/phpspec/blob/eb0d939b235f6091a8439a2a2fc144c9e0d5f569/src/PhpSpec/CodeAnalysis/TokenizedNamespaceResolver.php#L119

Homebrew issue: https://github.com/Homebrew/homebrew-core/issues/78635

Test script:
---------------
<?php

$matches = [];
$test = ' App\Domain\Repository\MetaData\SomethingRepositoryInterface';

preg_match('/\\\\([^\\\\]+)\s*$/', $test, $matches);
var_dump($matches);

$test2 = ' App\Domain\Exception\NotFoundException';

preg_match('/\\\\([^\\\\]+)\s*$/', $test2, $matches);
var_dump($matches);

Expected result:
----------------
array(2) {
  [0]=>
  string(29) "\SomethingRepositoryInterface"
  [1]=>
  string(28) "SomethingRepositoryInterface"
}
array(2) {
  [0]=>
  string(18) "\NotFoundException"
  [1]=>
  string(17) "NotFoundException"
}

Actual result:
--------------
array(0) {
}
array(2) {
  [0]=>
  string(18) "\NotFoundException"
  [1]=>
  string(17) "NotFoundException"
}

-- 
Edit bug report at https://bugs.php.net/bug.php?id=81101&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81101&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81101&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81101&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81101&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81101&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81101&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81101&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81101&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81101&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81101&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81101&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81101&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81101&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81101&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81101&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81101&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81101&r=mysqlcfg


Thread (10 messages)

« previous php.bugs (#234186) next »