summaryrefslogtreecommitdiff
path: root/test/ruby/test_regexp.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2020-11-23 11:03:15 -0800
committerBenoit Daloze <eregontp@gmail.com>2020-11-24 16:01:30 +0100
commitb26d6c70e0f08050ca23388bb0e8442f73269c73 (patch)
tree04385765f23c92077edd5c37b35cd93344ddb1ee /test/ruby/test_regexp.rb
parent237cb94cf5676e8cfc81ca9f5e8d29e04e61fc4d (diff)
Detect the premature end of char property in regexp
Default to ONIGERR_INVALID_CHAR_PROPERTY_NAME in fetch_char_property_to_ctype and only set otherwise if an ending } is found. Fixes [Bug #17340]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3807
Diffstat (limited to 'test/ruby/test_regexp.rb')
-rw-r--r--test/ruby/test_regexp.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index 231fd392d1..220e2b78ae 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -57,6 +57,17 @@ class TestRegexp < Test::Unit::TestCase
assert_equal('Ruby', 'Ruby'.sub(/[^a-z]/i, '-'))
end
+ def test_premature_end_char_property
+ ["\\p{",
+ "\\p{".dup.force_encoding("UTF-8"),
+ "\\p{".dup.force_encoding("US-ASCII")
+ ].each do |string|
+ assert_raise(RegexpError) do
+ Regexp.new(string)
+ end
+ end
+ end
+
def test_assert_normal_exit
# moved from knownbug. It caused core.
Regexp.union("a", "a")