diff options
| author | Hiroya Fujinami <make.just.on@gmail.com> | 2026-04-29 11:09:24 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-29 11:09:24 +0900 |
| commit | 493d26dcdea8b2f0ac5d28e057b401bc809e7fae (patch) | |
| tree | 3bedb8fb01dce5419d845f58bc0ff36f39b188ec /test | |
| parent | 1c39cc81159083e0c822362691bc3e35b2bddb00 (diff) | |
Reject overflowed repeat/null-check IDs in huge regexps (#16801)
Add explicit errors for excessive range-repeat and null-check IDs;
map new errors in regerror; add regression tests for oversized generated
patterns.
Diffstat (limited to 'test')
| -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 c85484d819..d545d983dc 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -2350,4 +2350,16 @@ class TestRegexp < Test::Unit::TestCase assert_match(/[x#{e_acute_lower}]/i, "CAF#{e_acute_upper}", "should match e acute case insensitive") end end + + def test_too_many_range_repeat + source = '(?:foobar){0,100}' * 100000 + assert_raise(RegexpError) { Regexp.new(source) } + assert_raise(SyntaxError) { eval("/#{source}/") } + end + + def test_too_many_null_check + source = '(?:(?:foo)?|(?:bar)?)*' * 100000 + assert_raise(RegexpError) { Regexp.new(source) } + assert_raise(SyntaxError) { eval("/#{source}/") } + end end |
