diff options
author | Nobuyoshi Nakada <[email protected]> | 2023-12-01 14:52:47 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2023-12-01 15:04:30 +0900 |
commit | e36b9760fd0eb3bffbf1536106ce3cce02816c1f (patch) | |
tree | 498f61545cfa2c3945378e6b679ad2f96259a5d2 | |
parent | d503e1b95a40e45d7767e0175de60092de4ba54e (diff) |
Dispatch invalid hex escape content too
-rw-r--r-- | parse.y | 2 | ||||
-rw-r--r-- | test/ripper/test_scanner_events.rb | 8 |
2 files changed, 6 insertions, 4 deletions
@@ -7791,7 +7791,7 @@ tok_hex(struct parser_params *p, size_t *numlen) c = (int)ruby_scan_hex(p->lex.pcur, 2, numlen); if (!*numlen) { yyerror0("invalid hex escape"); - token_flush(p); + dispatch_scan_event(p, tSTRING_CONTENT); return 0; } p->lex.pcur += *numlen; diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb index 9739cdb1eb..792f19ef1a 100644 --- a/test/ripper/test_scanner_events.rb +++ b/test/ripper/test_scanner_events.rb @@ -997,13 +997,15 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase assert_equal [:on_parse_error, "Invalid escape character syntax", "\\C-\u{3042}"], err end - def test_invalid_hex_escape + def test_invalid_hex_escape_string err = nil - assert_equal ['U'], scan('tstring_content', '"\\xU"') {|*e| err = e} + assert_equal ['\\x', 'U'], scan('tstring_content', '"\\xU"') {|*e| err = e} assert_equal [:on_parse_error, "invalid hex escape", "\\x"], err + end + def test_invalid_hex_escape_regexp err = nil - assert_equal ['U'], scan('tstring_content', '/\\xU/') {|*e| err = e} + assert_equal ['\\x', 'U'], scan('tstring_content', '/\\xU/') {|*e| err = e} assert_equal [:on_parse_error, "invalid hex escape", "\\x"], err end |