From 41caa233bb6324a7ba9b7930da18c7858b1fffe8 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Thu, 10 Feb 2022 18:24:04 +0800 Subject: [PATCH] Fix string parsing. --- src/tokenizer.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 9857bf78..8d3c70b2 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -1192,8 +1192,13 @@ pub fn parse_string_literal( // Close wrapper if termination_char == next_char && escape.is_empty() { - state.is_within_text_terminated_by = None; - break; + // Double wrapper + if stream.peek_next().map_or(false, |c| c == termination_char) { + eat_next(stream, pos); + } else { + state.is_within_text_terminated_by = None; + break; + } } if first_char.is_none() { @@ -1267,15 +1272,6 @@ pub fn parse_string_literal( result.push(next_char) } - // Double wrapper - _ if termination_char == next_char - && escape.is_empty() - && stream.peek_next().map_or(false, |c| c == termination_char) => - { - eat_next(stream, pos); - result.push(termination_char) - } - // Verbatim '\n' if verbatim => { assert_eq!(escape, "", "verbatim strings should not have any escapes");