mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 22:45:03 +02:00
Fix update_coderange for binary strings
Although a binary (aka ASCII-8BIT) string will never have a broken coderange, it still has to differentiate between "valid" and "7bit". On Ruby 3.4/trunk this problem is masked because we now clear the coderange more agressively in rb_str_resize, and we happened to always be strinking this string, but we should not assume that. On Ruby 3.3 this created strings where `ascii_only?` was true in cases it shouldn't be as well as other problems. Fixes [Bug #20883] Co-authored-by: Daniel Colson <danieljamescolson@gmail.com> Co-authored-by: Matthew Draper <matthew@trebex.net>
This commit is contained in:
parent
51ffef2819
commit
1f6dd9071c
Notes:
git
2024-11-09 01:39:37 +00:00
2 changed files with 9 additions and 2 deletions
|
@ -546,4 +546,12 @@ class TestSprintf < Test::Unit::TestCase
|
|||
sprintf("%*s", RbConfig::LIMITS["INT_MIN"], "")
|
||||
end
|
||||
end
|
||||
|
||||
def test_binary_format_coderange
|
||||
1.upto(500) do |i|
|
||||
str = sprintf("%*s".b, i, "\xe2".b)
|
||||
refute_predicate str, :ascii_only?
|
||||
assert_equal i, str.bytesize
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue