From 716e9cf779fca36ade7328837acc01c53d7fcf76 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sat, 10 Apr 2021 11:11:42 +0800 Subject: [PATCH] Fix string parsing state. --- src/token.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/token.rs b/src/token.rs index 7f454667..4d7bbdb1 100644 --- a/src/token.rs +++ b/src/token.rs @@ -895,8 +895,13 @@ pub fn parse_string_literal( pos.advance(); ch } + None if !continuation && !verbatim => { + pos.advance(); + state.is_within_text_terminated_by = None; + return Err((LERR::UnterminatedString, *pos)); + } None => { - if !continuation || escape != "\\" { + if verbatim || escape != "\\" { result += &escape; } pos.advance(); @@ -1005,6 +1010,7 @@ pub fn parse_string_literal( // Cannot have new-lines inside non-multi-line string literals '\n' if !escape.is_empty() || !verbatim => { pos.rewind(); + state.is_within_text_terminated_by = None; return Err((LERR::UnterminatedString, *pos)); }