diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-12-01 13:04:42 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-12-01 15:04:30 +0900 |
commit | d503e1b95a40e45d7767e0175de60092de4ba54e (patch) | |
tree | 3804881a722be63f4a2b6952cf6f6198fd615c80 /parse.y | |
parent | 52c2660163240a494b65eb9942c3978896ed807b (diff) | |
download | ruby-d503e1b95a40e45d7767e0175de60092de4ba54e.tar.gz |
[Bug #20030] dispatch invalid escaped character without ignoring it
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -7878,6 +7878,16 @@ tokadd_codepoint(struct parser_params *p, rb_encoding **encp, static int tokadd_mbchar(struct parser_params *p, int c); +static int +tokskip_mbchar(struct parser_params *p) +{ + int len = parser_precise_mbclen(p, p->lex.pcur-1); + if (len > 0) { + p->lex.pcur += len - 1; + } + return len; +} + /* return value is for ?\u3042 */ static void tokadd_utf8(struct parser_params *p, rb_encoding **encp, @@ -8065,7 +8075,11 @@ read_escape(struct parser_params *p, int flags) } else if (c == '?') return 0177; - else if (c == -1 || !ISASCII(c)) goto eof; + else if (c == -1) goto eof; + else if (!ISASCII(c)) { + tokskip_mbchar(p); + goto eof; + } else { int c2 = escaped_control_code(c); if (c2) { @@ -8093,7 +8107,7 @@ read_escape(struct parser_params *p, int flags) eof: case -1: yyerror0("Invalid escape character syntax"); - token_flush(p); + dispatch_scan_event(p, tSTRING_CONTENT); return '\0'; default: |