mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[Bug #20784] Fix incomplete character syntax followed by EOF
This commit is contained in:
parent
e939f28cc9
commit
6743e6285a
Notes:
git
2024-10-05 06:59:19 +00:00
2 changed files with 5 additions and 1 deletions
2
parse.y
2
parse.y
|
@ -10118,7 +10118,7 @@ parse_qmark(struct parser_params *p, int space_seen)
|
|||
enc = rb_utf8_encoding();
|
||||
tokadd_utf8(p, &enc, -1, 0, 0);
|
||||
}
|
||||
else if (!ISASCII(c = peekc(p))) {
|
||||
else if (!ISASCII(c = peekc(p)) && c != -1) {
|
||||
nextc(p);
|
||||
if (tokadd_mbchar(p, c) == -1) return 0;
|
||||
}
|
||||
|
|
|
@ -951,6 +951,10 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
|
|||
assert_equal ["?\\u{41}"],
|
||||
scan('CHAR', "?\\u{41}")
|
||||
|
||||
err = nil
|
||||
assert_equal [], scan('CHAR', '?\\') {|*e| err = e}
|
||||
assert_equal([:on_parse_error, "Invalid escape character syntax", "?\\"], err)
|
||||
|
||||
err = nil
|
||||
assert_equal [], scan('CHAR', '?\\M ') {|*e| err = e}
|
||||
assert_equal([:on_parse_error, "Invalid escape character syntax", "?\\M "], err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue