[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/
Issue #22451 has been updated by byroot (Jean Boussier). 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. ---------------------------------------- Bug #22451: Coderange may be set incorrectly when concatenating a string into itself https://bugs.ruby-lang.org/issues/22451#change-119560 * Author: jhawthorn (John Hawthorn) * Status: Open * Backport: 3.3: WONTFIX, 3.4: REQUIRED, 4.0: REQUIRED ---------------------------------------- ```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/
Issue #22451 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.3: WONTFIX, 3.4: REQUIRED, 4.0: REQUIRED to 3.3: WONTFIX, 3.4: DONE, 4.0: REQUIRED Merged into `ruby_3_4` at https://github.com/ruby/ruby/commit/98ba0a86a3b15a94d24ef1c281cd1b48f73c793e ---------------------------------------- Bug #22451: Coderange may be set incorrectly when concatenating a string into itself https://bugs.ruby-lang.org/issues/22451#change-119781 * Author: jhawthorn (John Hawthorn) * Status: Closed * Backport: 3.3: WONTFIX, 3.4: DONE, 4.0: REQUIRED ---------------------------------------- ```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/
Issue #22451 has been updated by tenderlovemaking (Aaron Patterson). Backport changed from 3.3: WONTFIX, 3.4: DONE, 4.0: REQUIRED to 3.3: WONTFIX, 3.4: DONE, 4.0: DONE ruby_4_0 commit:ccb92217d3 merged revision(s) commit:b740f7d553. ---------------------------------------- Bug #22451: Coderange may be set incorrectly when concatenating a string into itself https://bugs.ruby-lang.org/issues/22451#change-119867 * Author: jhawthorn (John Hawthorn) * Status: Closed * Backport: 3.3: WONTFIX, 3.4: DONE, 4.0: DONE ---------------------------------------- ```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/
participants (4)
-
byroot (Jean Boussier) -
jhawthorn (John Hawthorn) -
nagachika (Tomoyuki Chikanaga) -
tenderlovemaking (Aaron Patterson)