Project

General

Profile

Actions

Bug #20883

closed

sprintf with binary strings has incorrect coderange

Added by jhawthorn (John Hawthorn) 10 days ago. Updated 9 days ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x86_64-linux]
[ruby-core:119855]

Description

In 9dc6065 we stopped updating the coderange when the encoding became ENCINDEX_ASCII_8BIT. Though ASCII-8BIT (binary) can't ever have a broken coderange, it does need to distinguish between 7bit and valid.

puts ("%s" % "\xe2".b).ascii_only?
# => false from Ruby 2.1 to 3.1
# => true (incorrect) on Ruby 3.2 and 3.3
# => false again on HEAD

This was fixed in master as part of #20189, which clears the coderange in more cases of rb_str_resize which happens to fix this, but we shouldn't rely on it.

https://github.com/ruby/ruby/pull/12029

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0