From: jiri.marsik@... Date: 2020-11-24T11:19:07+00:00 Subject: [ruby-core:101049] [Ruby master Bug#17340] /\p{/ matches newline instead of throwing syntax error Issue #17340 has been updated by jirkamarsik (Jirka Marsik). Great, thanks! ---------------------------------------- Bug #17340: /\p{/ matches newline instead of throwing syntax error https://bugs.ruby-lang.org/issues/17340#change-88720 * Author: jirkamarsik (Jirka Marsik) * Status: Open * Priority: Normal * ruby -v: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- The regular expression `/\p{/` matches newline characters instead of reporting a syntax error. ``` irb(main):001:0> /\p{/.match("\n") => # ``` The issue stems from the function `fetch_char_property_to_ctype` in `regparse.c`. If the Unicode character property escape is not terminated with a right brace or some of the other unacceptable characters, the method will return 0 and will not be considered a failure. The number 0 is then interpreted as a `ctype` code which stands for the newline character property. Thus, this expression will end up matching newlines. I would guess that the intended behavior here would be to report a syntax error in the regular expression. -- https://bugs.ruby-lang.org/ Unsubscribe: