Bug 1715472 - PHP (pcre2) can't handle regular expression
Summary: PHP (pcre2) can't handle regular expression
Keywords:
Status: CLOSED DUPLICATE of bug 1706742
Alias: None
Product: Fedora
Classification: Fedora
Component: pcre2
Version: 30
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Petr Pisar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-05-30 12:50 UTC by Ernesto
Modified: 2019-05-30 13:10 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2019-05-30 13:10:44 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
PHP test (117 bytes, application/x-php)
2019-05-30 12:50 UTC, Ernesto
no flags Details

Description Ernesto 2019-05-30 12:50:06 UTC
Created attachment 1575214 [details]
PHP test

Description of problem:

When trying to match against this valid pattern /([nesw'",\X])|((?:[0-9]+)(?:[\.][0-9]+)?(?:e[+-]?[0-9]+)?)|\s+/i in PHP will result in the following message:

PHP Warning:  preg_match(): Compilation failed: escape sequence is invalid.

Version-Release number of selected component (if applicable):

pcre2-10.33-2.fc30
PHP 7.3.5 (or 7.3.6 from remi).

How reproducible:

Always.

Steps to Reproduce:
1. Install PHP (depends on latest pcre2-10.33-2.fc30).
2. In PHP, use preg_match o preg_split against the described pattern (or run the attached test).

Actual results:

PHP Warning:  preg_match(): Compilation failed: escape sequence is invalid.

Expected results:

No error message. The pattern is valid.

Additional info:

Th problem seems to be in pcre2, on which PHP depends. It works with pcre2-10.32-9.fc30, broken in pcre2-10.33-2.fc30.

PHP test attached.

Comment 1 Petr Pisar 2019-05-30 13:10:44 UTC
The regular expression can be reduced to /[\X]/:

$ printf '%s\n' '/[\X]/' | pcre2test 
PCRE2 version 10.33 2019-04-16
/[\X]/
Failed: error 107 at offset 2: escape sequence is invalid in character class

And no, this is not a regression in PCRE2 since PCRE2-10.32 also refuses the expression:

$ printf '%s\n' '/[\X]/' | ./pcre2test 
PCRE2 version 10.32 2018-09-10
/[\X]/
Failed: error 107 at offset 2: invalid escape sequence in character class

This behavior is in line with PCRE2 documentation because \X escape sequence is not allowed in character classes.

This "change" has already been reported in bug #1706742. Closing as a duplicate. See more details there.

*** This bug has been marked as a duplicate of bug 1706742 ***


Note You need to log in before you can comment on or make changes to this bug.