Skip to content

Bug in one or more quantifier since PCRE10.35/PHP7.4.12 #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mickmackusa opened this issue Jul 9, 2022 · 4 comments
Closed

Bug in one or more quantifier since PCRE10.35/PHP7.4.12 #133

mickmackusa opened this issue Jul 9, 2022 · 4 comments

Comments

@mickmackusa
Copy link

Reproduce with: 3v4l Demo

$txt = <<<TEXT
foo {
     A
}

foo {
     A
}

foo {
     B
}

foo {
     A
}

foo {
     C
}
TEXT;
echo preg_replace('/\R{0,2}.+{[^}]*A[^}]*}/', '', $txt);

Expected Result:

foo {
     B
}

foo {
     C
}

Actual Result:

foo {
     B
}

foo {
     A
}

foo {
     C
}
@cmb69
Copy link

cmb69 commented Jul 11, 2022

I can reproduce this with pcre2test (build form 3e52db5):

cmb@ELEPHPANT:~$ pcre2test test.txt
PCRE2 version 10.41 2022-xx-xx
/\n{0,2}.+{[^}]*A[^}]*}/g
foo {\n    A\n}\n\nfoo {\n    A\n}\n\nfoo {\n    B\n}\n\nfoo {\n    A\n}\n\nfoo {\n    C\n}
 0: foo {\x0a    A\x0a}
 0: \x0a\x0afoo {\x0a    A\x0a}
 0: \x0a\x0afoo {\x0a    A\x0a}
cmb@ELEPHPANT:~$ pcre2test -jit test.txt
PCRE2 version 10.41 2022-xx-xx
/\n{0,2}.+{[^}]*A[^}]*}/g
foo {\n    A\n}\n\nfoo {\n    A\n}\n\nfoo {\n    B\n}\n\nfoo {\n    A\n}\n\nfoo {\n    C\n}
 0: foo {\x0a    A\x0a}
 0: \x0a\x0afoo {\x0a    A\x0a}

So this looks like a JIT issue.

@zherczeg
Copy link
Collaborator

Thank you for the report. Proposed fix: #135

@cmb69
Copy link

cmb69 commented Jul 12, 2022

Thank you for the quick reply! I can confirm that #135 solves this issue for me, and apparently causes no unwanted side effects.

@PhilipHazel
Copy link
Collaborator

#135 is now merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants