Merge pull request #292 from github/regexp_slash_az

Don't parse `\A` and `\Z` as `RegExpConstant`
This commit is contained in:
Nick Rolfe
2021-09-17 16:42:13 +01:00
committed by GitHub
4 changed files with 24 additions and 17 deletions

View File

@@ -146,10 +146,10 @@ regexp.rb:
# 19| [RegExpConstant, RegExpNormalChar] _
# 20| [RegExpConstant, RegExpEscape] \A
# 20| [RegExpCaret] \A
# 20| [RegExpSequence] \A[+-]?\d+
#-----| 0 -> [RegExpConstant, RegExpEscape] \A
#-----| 0 -> [RegExpCaret] \A
#-----| 1 -> [RegExpOpt] [+-]?
#-----| 2 -> [RegExpPlus] \d+

View File

@@ -33,7 +33,10 @@ class FooController < ActionController::Base
# GOOD - guarded by a string length check
if name.length < 1024
name.gsub regex, ''
name.gsub regex, ''
end
# GOOD - regex does not suffer from polynomial backtracking (regression test)
params[:foo] =~ /\A[bc].*\Z/
end
end
end