Skip to content

gen_stub: fix regexps with unintentional range due to - character placement #12004

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

Merged
merged 1 commit into from
Aug 20, 2023

Conversation

Ayesh
Copy link
Member

@Ayesh Ayesh commented Aug 20, 2023

[A-Za-z0-9_-|] regex range is interpreted as any character in ranges A-Z, a-z, 0-9, and _-|. The last three characters (_-|) are interpretted as a range, because the dash character is placed between _ and |. This means the regexp matches any ASCII character between ASCII index 95 and 124. This means that this expression unexpectedly (?) matches characters such as \`` and {`

This changes the regexp to place the dash character at the end, so instead of any character in ASCII 95-124, it only matches -, |, and _ characters only.

image
Regex101 also highlighting this: https://regex101.com/r/gEq3wc/1

Copy link
Member

@kocsismate kocsismate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@kocsismate kocsismate merged commit e6627cc into php:master Aug 20, 2023
jorgsowa pushed a commit to jorgsowa/php-src that referenced this pull request Aug 24, 2023
@Ayesh Ayesh deleted the gen_stub/regex-range-fix branch February 27, 2024 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants