From: "kddnewton (Kevin Newton) via ruby-core" Date: 2026-11-28T18:22:28+00:00 Subject: [ruby-core:127757] [Ruby Bug#22653] parse.y rb_enc_isspace incorrect usage in parse_qmark Issue #22653 has been reported by kddnewton (Kevin Newton). ---------------------------------------- Bug #22653: parse.y rb_enc_isspace incorrect usage in parse_qmark https://bugs.ruby-lang.org/issues/22653 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- This is somewhat confusing. Basically parse.y is looking for a space character after a question mark to determine if the ? is an operator or not. This matches the ASCII space character, and in some encodings matches a non-ASCII space character like 0xA0 in ISO-8859-1 (non-breaking space). This gets weird in UTF-8. parse.y calls `rb_enc_isspace(c, p->enc)`, but the signature is `rb_enc_isspace(OnigCodePoint c, rb_encoding *enc)`. So it's passing a byte where the function expects a codepoint. So in UTF-8, if parse.y sees 0xA0 (an invalid codepoint sequence in UTF-8) the function will return true because that codepoint maps to non-breaking space, even though that byte doesn't. I think this is incorrect. I think it should do one of the following: * decode a full codepoint in the source encoding (in UTF-8 this would be 0xC2 0xA0) to match a space * support only 1-byte space characters in the source encoding (like 0x20 and 0xA0 in ISO-8859-1) to match a space * match only ASCII space characters (only 0x20) I'm fine with any of these options, but at minimum the current implementation is confusing. -- 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/