diff options
| author | NARUSE, Yui <nurse@users.noreply.github.com> | 2024-03-21 02:13:59 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-20 17:13:59 +0000 |
| commit | 00cb72157a60c20a9b9d9fe81fc974ea83d672b4 (patch) | |
| tree | 3f5d238c1e7aabcd6222beefa5c95b5679510bd3 /test/ruby | |
| parent | c626c201e4129bbea17583ecef73472c6f668c81 (diff) | |
merge revision(s) 3e6e3ca2627b1aa71b17de902cc1b8188246a828: [Backport #20207] (#10299)
Correctly handle consecutive lookarounds (#9738)
Fix [Bug #20207]
Fix [Bug #20212]
Handling consecutive lookarounds in init_cache_opcodes is buggy, so it
causes invalid memory access reported in [Bug #20207] and [Bug #20212].
This fixes it by using recursive functions to detected lookarounds
nesting correctly.
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_regexp.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 4e04ccee69..84318ada31 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -2033,6 +2033,18 @@ class TestRegexp < Test::Unit::TestCase assert /^(?:.+){2,4}?b|b/.match? "aaaabaa" end + def test_bug_20207 # [Bug #20207] + assert(!'clan'.match?(/(?=.*a)(?!.*n)/)) + end + + def test_bug_20212 # [Bug #20212] + regex = Regexp.new( + /\A((?=.*?[a-z])(?!.*--)[a-z\d]+[a-z\d-]*[a-z\d]+).((?=.*?[a-z])(?!.*--)[a-z\d]+[a-z\d-]*[a-z\d]+).((?=.*?[a-z])(?!.*--)[a-zd]+[a-zd-]*[a-zd]+).((?=.*?[a-z])(?!.*--)[a-zd]+[a-zd-]*[a-zd]+)\Z/x + ) + string = "www.google.com" + 100.times.each { assert(regex.match?(string)) } + end + def test_linear_time_p assert_send [Regexp, :linear_time?, /a/] assert_send [Regexp, :linear_time?, 'a'] |
