summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNARUSE, Yui <nurse@users.noreply.github.com>2024-03-20 22:40:46 +0900
committerGitHub <noreply@github.com>2024-03-20 13:40:46 +0000
commitce372be903e5f3597f1dc83cb558f165850b3bee (patch)
tree9e58063291d7163c9a616688d748c4425cb21f8b /test
parent69cee6fee50f63cd52d59325dc3780a6fc4e5ae2 (diff)
merge revision(s) ade56737e2273847426214035c0ff2340b43799a: [Backport #20190] (#10300)
Fix coderange of invalid_encoding_string.<<(ord) Appending valid encoding character can change coderange from invalid to valid. Example: "\x95".force_encoding('sjis')<<0x5C will be a valid string "\x{955C}"
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_string.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 4aa119f8fd..42f2544b5a 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -301,6 +301,9 @@ CODE
assert_raise(RangeError, bug) {S("a".force_encoding(Encoding::UTF_8)) << -1}
assert_raise(RangeError, bug) {S("a".force_encoding(Encoding::UTF_8)) << 0x81308130}
assert_nothing_raised {S("a".force_encoding(Encoding::GB18030)) << 0x81308130}
+
+ s = "\x95".force_encoding(Encoding::SJIS).tap(&:valid_encoding?)
+ assert_predicate(s << 0x5c, :valid_encoding?)
end
def test_MATCH # '=~'