[ruby-core:127299] [Ruby Bug#22495] UTF-32 strings with a byte 0x80 or more in the most significant position are reported as valid
Issue #22495 has been reported by mame (Yusuke Endoh). ---------------------------------------- Bug #22495: UTF-32 strings with a byte 0x80 or more in the most significant position are reported as valid https://bugs.ruby-lang.org/issues/22495 * Author: mame (Yusuke Endoh) * Status: Open * Backport: 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED ---------------------------------------- `String#valid_encoding?` returns `true` for UTF-32 sequences whose code point is 0x80000000 or more, when Ruby is built with gcc -O2. ```ruby "\xff\xff\xff\xff".force_encoding("UTF-32BE").valid_encoding? #=> true (expected: false) "\x00\x00\x00\x80".force_encoding("UTF-32LE").valid_encoding? #=> true (expected: false) "\xff\xff\xff\xff".force_encoding("UTF-32BE").ord #=> 4294967295 (expected: ArgumentError) ``` @make_now_just found this and wrote the fix. -- https://bugs.ruby-lang.org/
Issue #22495 has been updated by mame (Yusuke Endoh). https://github.com/ruby/ruby/pull/19646 ---------------------------------------- Bug #22495: UTF-32 strings with a byte 0x80 or more in the most significant position are reported as valid https://bugs.ruby-lang.org/issues/22495#change-119724 * Author: mame (Yusuke Endoh) * Status: Open * Backport: 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED ---------------------------------------- `String#valid_encoding?` returns `true` for UTF-32 sequences whose code point is 0x80000000 or more, when Ruby is built with gcc -O2. ```ruby "\xff\xff\xff\xff".force_encoding("UTF-32BE").valid_encoding? #=> true (expected: false) "\x00\x00\x00\x80".force_encoding("UTF-32LE").valid_encoding? #=> true (expected: false) "\xff\xff\xff\xff".force_encoding("UTF-32BE").ord #=> 4294967295 (expected: ArgumentError) ``` @make_now_just found this and wrote the fix. -- https://bugs.ruby-lang.org/
Issue #22495 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: DONE, 4.0: REQUIRED ruby_3_4 commit:c95be3338428729e1699b00d9786c825ec7bef3e merged revision(s) commit:e1a9429918d5ead25a00f79a92f750abbeaa519a. ---------------------------------------- Bug #22495: UTF-32 strings with a byte 0x80 or more in the most significant position are reported as valid https://bugs.ruby-lang.org/issues/22495#change-119935 * Author: mame (Yusuke Endoh) * Status: Closed * Backport: 3.3: REQUIRED, 3.4: DONE, 4.0: REQUIRED ---------------------------------------- `String#valid_encoding?` returns `true` for UTF-32 sequences whose code point is 0x80000000 or more, when Ruby is built with gcc -O2. ```ruby "\xff\xff\xff\xff".force_encoding("UTF-32BE").valid_encoding? #=> true (expected: false) "\x00\x00\x00\x80".force_encoding("UTF-32LE").valid_encoding? #=> true (expected: false) "\xff\xff\xff\xff".force_encoding("UTF-32BE").ord #=> 4294967295 (expected: ArgumentError) ``` @make_now_just found this and wrote the fix. -- https://bugs.ruby-lang.org/
Issue #22495 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.3: REQUIRED, 3.4: DONE, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ruby_4_0 commit:cf49695957fcedead271b95ec9ae7a0cbf139c62 merged revision(s) commit:e1a9429918d5ead25a00f79a92f750abbeaa519a. ---------------------------------------- Bug #22495: UTF-32 strings with a byte 0x80 or more in the most significant position are reported as valid https://bugs.ruby-lang.org/issues/22495#change-119996 * Author: mame (Yusuke Endoh) * Status: Closed * Backport: 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ---------------------------------------- `String#valid_encoding?` returns `true` for UTF-32 sequences whose code point is 0x80000000 or more, when Ruby is built with gcc -O2. ```ruby "\xff\xff\xff\xff".force_encoding("UTF-32BE").valid_encoding? #=> true (expected: false) "\x00\x00\x00\x80".force_encoding("UTF-32LE").valid_encoding? #=> true (expected: false) "\xff\xff\xff\xff".force_encoding("UTF-32BE").ord #=> 4294967295 (expected: ArgumentError) ``` @make_now_just found this and wrote the fix. -- https://bugs.ruby-lang.org/
participants (3)
-
k0kubun (Takashi Kokubun) -
mame (Yusuke Endoh) -
nagachika (Tomoyuki Chikanaga)