diff options
author | nagachika <nagachika@ruby-lang.org> | 2021-10-03 16:16:18 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2021-10-03 16:16:18 +0900 |
commit | f192e01233ccd7966721a164e62a86707b4e6d9e (patch) | |
tree | ba927a691d1db63f11f2105411ce3a471f1e1e5d /test | |
parent | 5341eca588e738cd5031ab7d8bb5c300471c00e9 (diff) |
merge revision(s) 7c0230b05d0978958f89434c84ddd9c82419c1a5,552728a23aeab0df598b356b19a573259e297d14,49af9012a20a824542cf588e55e5488895553e09: [Backport #18184]
Check the entire name as `ruby2_keywords_flag` [Bug #18184]
---
marshal.c | 2 +-
test/ruby/test_marshal.rb | 8 +++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
Check the encoding of `ruby2_keywords_flag` [Bug #18184]
---
marshal.c | 1 +
test/ruby/test_marshal.rb | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
Prohibit invalid encoding symbols [Bug #18184]
---
marshal.c | 8 +++++++-
test/ruby/test_marshal.rb | 10 +++++++---
2 files changed, 14 insertions(+), 4 deletions(-)
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_marshal.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index ef8b261321..43bdadccb0 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -785,8 +785,22 @@ class TestMarshal < Test::Unit::TestCase def test_marshal_with_ruby2_keywords_hash flagged_hash = ruby2_keywords_hash(key: 42) - hash = Marshal.load(Marshal.dump(flagged_hash)) + data = Marshal.dump(flagged_hash) + hash = Marshal.load(data) assert_equal(42, ruby2_keywords_test(*[hash])) + + hash2 = Marshal.load(data.sub(/\x06K(?=T\z)/, "\x08KEY")) + assert_raise(ArgumentError, /\(given 1, expected 0\)/) { + ruby2_keywords_test(*[hash2]) + } + end + + def test_invalid_byte_sequence_symbol + data = Marshal.dump(:K) + data = data.sub(/:\x06K/, "I\\&\x06:\x0dencoding\"\x0dUTF-16LE") + assert_raise(ArgumentError, /UTF-16LE: "\\x4B"/) { + Marshal.load(data) + } end def exception_test |