From cf2bbcfff2985c116552967c7c4522f4630f2d18 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 11 Jun 2021 00:06:43 +0900 Subject: Just free compiled pattern if no space is used https://hackerone.com/reports/1220911 --- test/ruby/test_regexp.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 4be6d7bec7..84687c5380 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -1431,6 +1431,15 @@ class TestRegexp < Test::Unit::TestCase assert_kind_of MatchData, /(?a)(?aa)\k/.match("aaaab") end + def test_invalid_group + assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") + begin; + assert_raise_with_message(RegexpError, /invalid conditional pattern/) do + Regexp.new("((?(1)x|x|)x)+") + end + end; + end + # This assertion is for porting x2() tests in testpy.py of Onigmo. def assert_match_at(re, str, positions, msg = nil) re = Regexp.new(re) unless re.is_a?(Regexp) -- cgit v1.2.3