-
Notifications
You must be signed in to change notification settings - Fork 94
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
"ss" in look-behind raises syntax error #92
Comments
I'm getting a similar error with a non-ascii string:
|
Seems like a pretty big deal since it means that lookbehind is now incompatible with non-ascii characters, under certain conditions. |
Just upgraded production to 2.4.2 (from 2.3.5) and encountered this problem with regexps like: /(?<!<strong>)(A\u2014a)(?!<\/strong>)/i # SyntaxError
/(?<!<st>)(A\u2014a)(?!<\/st>)/i # SyntaxError
/(?<!<s>)(A\u2014a)(?!<\/s>)/i # OK
/(?<!<sr>)(A\u2014a)(?!<\/sr>)/i # OK
/(?<!<strong>)(Aa)(?!<\/strong>)/i # OK
/(?<!<strong>)(A\u2014a)(?!<\/strong>)/ # OK It seems the problem goes as far back as 2.4.0 (and even 2.4.0-rc). 2.3.x is okay with all of the above. |
I just tested Ruby 2.5 (and Ruby 2.4.3) and no improvement. Is there a chance someone will fix this soon or is it considered a non-breaking bug? Thanks! |
works fine for ruby 2.3.3 For ruby 2.5.0-preview1
Just replace |
As @nurse mentioned, ss in some language is ß or ẞ, so the syntax tree is expanded as
equivalent to Now for So what is the problem of
equivalent to
|
Sorry for the very late response, but I haven't look into this yet. |
It seems that oniguruma has fixed the problem in kkos/oniguruma@257082d. |
Fixes #92. This fix was ported from oniguruma: kkos/oniguruma@257082d
@k-takata Late? Not even 2 years old ;) But seriously, big thanks for fixing this issue. :+9000: Do you know how long will it take for Ruby build to pick the fix up? Will it be automatically included in the next, say 2.5 or 2.6 patch? |
@nurse Will you include this in Ruby 2.5 and 2.6? |
This will be included into Ruby 2.7, but I don't have a plan to backport this into 2.6. |
FYI, I applied this changes on top of Ruby 2.6.6 and they effectively fix the issue see mauromorales/ruby@b2e52be @nurse Is there a way I could help you backport it to Ruby 2.6.6 or a newer version in 2.6? I also wouldn't mind doing the work for 2.7 (or any other version) I just need some guidance since I've never contributed to the ruby project. |
@nurse I just tried this in Ruby 2.7.2 and the problem persists |
I'm commenting on this closed issue to hopefully assist other searchers who land here looking for a workaround. Until Ruby uses the fixed version of Onigmo, you may find replacing the -/(?<!ass)/i
+/(?<!a[s][s])/i To test the patterns: buggy_pattern = /(?<!ass)/i
fixed_pattern = /(?<!a[s][s])/i
unicode_str = "😀"
unicode_str.match? buggy_pattern
# => raises RegexpError (invalid pattern in look-behind: /(?<!ass)/i)
unicode_str.match? fixed_pattern
# => true |
"ss" in look-behind may raise syntax error.
This seems because "ss" is expanded to "ß".
Though Onigmo avoids the issue if there's only "ss", but with another characters it cause error.
The text was updated successfully, but these errors were encountered: