php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74612 A backreference to a branch reset group
Submitted: 2017-05-18 14:58 UTC Modified: 2020-06-14 16:40 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: oleynikovny at mail dot ru Assigned: cmb (profile)
Status: Closed Package: PCRE related
PHP Version: 7.1.5 OS: GNU/Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: oleynikovny at mail dot ru
New email:
PHP Version: OS:

 

 [2017-05-18 14:58 UTC] oleynikovny at mail dot ru
Description:
------------
A backreference to a branch reset group works as expected in PHP 5 but not in PHP 7.

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

$string = '--';

$doesNotMatchInPhp7 = '/(?|(---)|(-))\1$/';
$matchesInPhp7 = '/(?|(-)|(---))\1$/';

var_dump(preg_match($doesNotMatchInPhp7, $string));
var_dump(preg_match($matchesInPhp7, $string));



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-18 14:59 UTC] oleynikovny at mail dot ru
-Summary: Usage of a back reference to a branch reset group +Summary: A back reference to a branch reset group
 [2017-05-18 14:59 UTC] oleynikovny at mail dot ru
Adjusted a summary.
 [2017-05-18 15:02 UTC] oleynikovny at mail dot ru
-Summary: A back reference to a branch reset group +Summary: A backreference to a branch reset group
 [2017-05-18 15:02 UTC] oleynikovny at mail dot ru
Adjusted a summary.
 [2017-05-18 16:05 UTC] requinix@php.net
https://3v4l.org/J6L3u

Works without JIT. https://3v4l.org/7dAic

Upstream bug?
 [2019-03-18 16:59 UTC] nikic@php.net
Looks like this got fixed in PHP 7.3 due to the update to PCRE2.

It looks like there also was a new PCRE1 release recently, but I'm not seeing this issue in the changelog.
 [2020-06-14 16:40 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-06-14 16:40 UTC] cmb@php.net
Indeed, works as expected with/without PCRE.JIT as of PHP 7.3.0,
so this ticket can be closed.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jun 07 10:01:26 2025 UTC