Skip to content
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

Invalid oniguruma nested lookarounds #24

Closed
RedCMD opened this issue Jan 5, 2025 · 2 comments
Closed

Invalid oniguruma nested lookarounds #24

RedCMD opened this issue Jan 5, 2025 · 2 comments

Comments

@RedCMD
Copy link

RedCMD commented Jan 5, 2025

Oniguruma does not support every combination of nested lookarounds

(?=), (?!), (?<!) and (?~) are not valid inside a lookbehind (?<=)

(?=), (?!) and () capture groups are not valid inside a negative lookbehind (?<!)

interesting JS does allow them

should be invalid
image

@slevithan
Copy link
Owner

slevithan commented Jan 5, 2025

Thanks for the report/details!

This is currently low priority since the JS handling is more permissive, so all valid Oniguruma lookbehinds should be handled correctly. But I agree it would be good to error in the same cases that Oniguruma would.


Note to self: Previously removed code in 696dcab might be adaptable for the new checks.

@slevithan
Copy link
Owner

slevithan commented Jan 6, 2025

low priority

I take this back, since using oniguruma-to-es to identify invalid Oniguruma regexes (as opposed to converting known-valid Oniguruma regexes) is an important use case that this library has always supported.

(?=), (?!), (?<!) and (?~) are not valid inside a lookbehind (?<=)

Re: (?~), only the absent stopper (?~|…) and range clear (?~|) forms are invalid within lookbehind (noted in the Oniguruma docs). Absent repeaters (?~…) and absent expressions (?~|…|…) are allowed within lookbehind (noted in #13 [for supporting absence operators], and I've just verified in Oniguruma).

slevithan added a commit that referenced this issue Jan 7, 2025
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

2 participants