Merge pull request #392 from schungx/master

Fix string parsing state.
This commit is contained in:
Stephen Chung 2021-04-10 12:45:27 +08:00 committed by GitHub
commit 10f334dbf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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));
}