From: "jhawthorn (John Hawthorn) via ruby-core" Date: 2026-10-16T21:55:42+00:00 Subject: [ruby-core:127151] [Ruby Bug#22451] Coderange may be set incorrectly when concatenating a string into itself Issue #22451 has been reported by jhawthorn (John Hawthorn). ---------------------------------------- Bug #22451: Coderange may be set incorrectly when concatenating a string into itself https://bugs.ruby-lang.org/issues/22451 * Author: jhawthorn (John Hawthorn) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- ```ruby 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 -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/