Bug #22653
openparse.y rb_enc_isspace incorrect usage in parse_qmark
Description
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.
No data to display