Skip to content

PCRE regular expressions with JIT enabled gives different result #11956

Closed
@antman3351

Description

@antman3351

Description

Hi,
The fallowing regex preg_match( '/<(\w+)[\s\w\-]+ id="S44_i89ew">/', '<br><div id="S44_i89ew">', $matches ); in PHP >= 8.1 gives different results if PCRE JIT is enabled or not. ( Note, I tried to simplify the regex to isolate the problem, that's why it doesn't make much sense ).

I had this problem with PHP 7.3 where I found a bug report that sated the problem was the PCRE library and not PHP.
I've recently migrated the code the regex is used in to PHP 8.2 and found there's still an issue, so I tested it on 3v4l.org and it seems to be fixed in PHP <= 8.0 and broken in 8.1.

I noted the issue on the PCRE2 github but the author doesn't think the issue is with any changes in the PCRE library: PCRE2Project/pcre2#261 (comment)

Code example: https://3v4l.org/189jh

Thanks,
Antonio

PHP Version

8.2.7

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions