summaryrefslogtreecommitdiff
path: root/spec/ruby/language/regexp
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2021-05-12 12:37:55 -0700
committerJeremy Evans <code@jeremyevans.net>2021-05-12 18:55:43 -0700
commit11ae581a4a7f5d5f5ec6378872eab8f25381b1b9 (patch)
treef250c8418f155fb0ee7f578085e2354bdbb7036a /spec/ruby/language/regexp
parent9484f9ebdf675f71811a5583c1af2415b26c932f (diff)
Fix handling of control/meta escapes in literal regexps
Ruby uses a recursive algorithm for handling control/meta escapes in strings (read_escape). However, the equivalent code for regexps (tokadd_escape) in did not use a recursive algorithm. Due to this, Handling of control/meta escapes in regexp did not have the same behavior as in strings, leading to behavior such as the following returning nil: ```ruby /\c\xFF/ =~ "\c\xFF" ``` Switch the code for handling \c, \C and \M in literal regexps to use the same code as for strings (read_escape), to keep behavior consistent between the two. Fixes [Bug #14367]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4495
Diffstat (limited to 'spec/ruby/language/regexp')
-rw-r--r--spec/ruby/language/regexp/interpolation_spec.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/spec/ruby/language/regexp/interpolation_spec.rb b/spec/ruby/language/regexp/interpolation_spec.rb
index ed0b724763..6951fd38ca 100644
--- a/spec/ruby/language/regexp/interpolation_spec.rb
+++ b/spec/ruby/language/regexp/interpolation_spec.rb
@@ -36,7 +36,7 @@ describe "Regexps with interpolation" do
it "gives precedence to escape sequences over substitution" do
str = "J"
- /\c#{str}/.to_s.should == '(?-mix:\c#' + '{str})'
+ /\c#{str}/.to_s.should include('{str}')
end
it "throws RegexpError for malformed interpolation" do