Project

General

Profile

Actions

Bug #22495

open

UTF-32 strings with a byte 0x80 or more in the most significant position are reported as valid

Bug #22495: UTF-32 strings with a byte 0x80 or more in the most significant position are reported as valid

Added by mame (Yusuke Endoh) 4 days ago. Updated 4 days ago.

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

Description

String#valid_encoding? returns true for UTF-32 sequences whose code point is 0x80000000 or more, when Ruby is built with gcc -O2.

"\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 (Hiroya Fujinami) found this and wrote the fix.

Actions

Also available in: PDF Atom