mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Do not make an incomplete escape a valid char
This commit is contained in:
parent
c40003da25
commit
b4365e75fd
2 changed files with 5 additions and 5 deletions
8
parse.y
8
parse.y
|
|
@ -6211,7 +6211,7 @@ tokadd_utf8(struct parser_params *p, rb_encoding **encp,
|
|||
|
||||
if (c != close_brace) {
|
||||
unterminated:
|
||||
literal_flush(p, p->lex.pcur);
|
||||
token_flush(p);
|
||||
yyerror0("unterminated Unicode escape");
|
||||
return;
|
||||
}
|
||||
|
|
@ -6221,11 +6221,10 @@ tokadd_utf8(struct parser_params *p, rb_encoding **encp,
|
|||
}
|
||||
else { /* handle \uxxxx form */
|
||||
if (!tokadd_codepoint(p, encp, regexp_literal, FALSE)) {
|
||||
token_flush(p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#define ESCAPE_CONTROL 1
|
||||
|
|
@ -6312,7 +6311,7 @@ read_escape(struct parser_params *p, int flags, rb_encoding **encp)
|
|||
eof:
|
||||
case -1:
|
||||
yyerror0("Invalid escape character syntax");
|
||||
pushback(p, c);
|
||||
token_flush(p);
|
||||
return '\0';
|
||||
|
||||
default:
|
||||
|
|
@ -6391,6 +6390,7 @@ tokadd_escape(struct parser_params *p, rb_encoding **encp)
|
|||
eof:
|
||||
case -1:
|
||||
yyerror0("Invalid escape character syntax");
|
||||
token_flush(p);
|
||||
return -1;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -938,7 +938,7 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
|
|||
|
||||
assert_equal ["?\\M-H"], scan('CHAR', '?\\M-H')
|
||||
err = nil
|
||||
assert_equal ["?\\M"], scan('CHAR', '?\\M ') {|*e| err = e}
|
||||
assert_equal [], scan('CHAR', '?\\M ') {|*e| err = e}
|
||||
assert_equal([:on_parse_error, "Invalid escape character syntax", "?\\M "], err)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue