From: jiri.marsik@... Date: 2021-06-28T09:30:02+00:00 Subject: [ruby-core:104423] [Ruby master Bug#18010] Character class with single character gets case-folded with following string Issue #18010 has been reported by jirkamarsik (Jirka Marsik). ---------------------------------------- Bug #18010: Character class with single character gets case-folded with following string https://bugs.ruby-lang.org/issues/18010 * Author: jirkamarsik (Jirka Marsik) * Status: Open * Priority: Normal * ruby -v: ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- ``` irb(main):001:0> /ff/i.match("\ufb00") => # irb(main):002:0> /[f]f/i.match("\ufb00") => # irb(main):003:0> /f[f]/i.match("\ufb00") => nil irb(main):004:0> /[f][f]/i.match("\ufb00") => nil irb(main):005:0> /(?:f)f/i.match("\ufb00") => nil irb(main):006:0> /f(?:f)/i.match("\ufb00") => nil irb(main):007:0> /(?:f)(?:f)/i.match("\ufb00") => nil ``` In the above, singleton character classes (`[...]`) and even parentheses (`(?:...)`) break up string literals, forcing each separate substring to be matched against separately. However, in the one case when a singleton character class precedes a string, it is joined with it as an optimization. However, this optimization ends up changing the semantics of the Regexp. -- https://bugs.ruby-lang.org/ Unsubscribe: