Project

General

Profile

Actions

Bug #22451

open

Coderange may be set incorrectly when concatenating a string into itself

Bug #22451: Coderange may be set incorrectly when concatenating a string into itself

Added by jhawthorn (John Hawthorn) 5 days ago. Updated 4 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:127151]

Description

s = "\x81\x30".force_encoding("GB18030")
#=> "\x810"
s.valid_encoding? # This is invalid
#=> false
(s + s).valid_encoding? # However it becomes valid when repeated
#=> true
(s << s).valid_encoding? # But concat assumed the coderange would not change
#=> false
s.b.force_encoding(s.encoding).valid_encoding? # Same bytes, different answer
#=> true

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

Updated by byroot (Jean Boussier) 4 days ago 1Actions #1 [ruby-core:127156]

  • Backport changed from 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.3: WONTFIX, 3.4: REQUIRED, 4.0: REQUIRED

Seems to have been present all the way since 1.9.

Actions

Also available in: PDF Atom