diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-08-13 16:45:51 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-10-15 16:48:25 +0900 |
commit | 7ffd14a18c341565afaf80d259f9fe5df8a13d29 (patch) | |
tree | 191416145775fd9defa2bb962b37fa3c1311a1a8 /test | |
parent | ab6c4f8be3dd0fb116ba2722a2fcdc53ad4ea0b7 (diff) | |
download | ruby-7ffd14a18c341565afaf80d259f9fe5df8a13d29.tar.gz |
Check encoding name to replicate
https://hackerone.com/reports/954433
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_encoding.rb | 8 | ||||
-rw-r--r-- | test/ruby/test_io_m17n.rb | 4 |
2 files changed, 9 insertions, 3 deletions
diff --git a/test/ruby/test_encoding.rb b/test/ruby/test_encoding.rb index 6fc5c48179..2965c0bc7b 100644 --- a/test/ruby/test_encoding.rb +++ b/test/ruby/test_encoding.rb @@ -61,7 +61,7 @@ class TestEncoding < Test::Unit::TestCase assert_instance_of(Encoding, Encoding::ISO_2022_JP.replicate("ISO-2022-JP-ANOTHER#{Time.now.to_f}")) bug3127 = '[ruby-dev:40954]' assert_raise(TypeError, bug3127) {Encoding::UTF_8.replicate(0)} - assert_raise(ArgumentError, bug3127) {Encoding::UTF_8.replicate("\0")} + assert_raise_with_message(ArgumentError, /\bNUL\b/, bug3127) {Encoding::UTF_8.replicate("\0")} END; end @@ -79,6 +79,12 @@ class TestEncoding < Test::Unit::TestCase assert_equal(e, (("x"*30).force_encoding(e)*1).encoding) GC.start + + name = "A" * 64 + Encoding.list.each do |enc| + assert_raise(ArgumentError) {enc.replicate(name)} + name.succ! + end end; end diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 7b37893514..27b16a2a36 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -776,10 +776,10 @@ EOT assert_equal(eucjp, r.read) end) - assert_raise_with_message(ArgumentError, /invalid name encoding/) do + assert_raise_with_message(ArgumentError, /invalid encoding name/) do with_pipe("UTF-8", "UTF-8".encode("UTF-32BE")) {} end - assert_raise_with_message(ArgumentError, /invalid name encoding/) do + assert_raise_with_message(ArgumentError, /invalid encoding name/) do with_pipe("UTF-8".encode("UTF-32BE")) {} end |