aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-12-01 13:04:42 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-12-01 15:04:30 +0900
commitd503e1b95a40e45d7767e0175de60092de4ba54e (patch)
tree3804881a722be63f4a2b6952cf6f6198fd615c80 /parse.y
parent52c2660163240a494b65eb9942c3978896ed807b (diff)
downloadruby-d503e1b95a40e45d7767e0175de60092de4ba54e.tar.gz
[Bug #20030] dispatch invalid escaped character without ignoring it
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y18
1 files changed, 16 insertions, 2 deletions
diff --git a/parse.y b/parse.y
index 865d26c0f3..1e59e832ec 100644
--- a/parse.y
+++ b/parse.y
@@ -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: