From 5c8e88d16b22b48267d841beada282f91dd45e4a Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Tue, 4 Aug 2020 02:18:48 -0400 Subject: [PATCH] remove panic on malformed bracketed list --- src/utils/read_until.rs | 2 +- tests/error.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/utils/read_until.rs b/src/utils/read_until.rs index e1dac0f..5eb4505 100644 --- a/src/utils/read_until.rs +++ b/src/utils/read_until.rs @@ -259,7 +259,7 @@ pub(crate) fn read_until_closing_square_brace( continue; } '\\' => { - t.push(toks.next().unwrap()); + t.push(tok); t.push(match toks.next() { Some(tok) => tok, None => continue, diff --git a/tests/error.rs b/tests/error.rs index ffa3fc1..997d9c2 100644 --- a/tests/error.rs +++ b/tests/error.rs @@ -245,4 +245,11 @@ error!( "a {foo: {bar: red", "Error: Expected identifier." ); error!(toplevel_nullbyte, "\u{0}", "Error: expected selector."); -error!(double_escaped_bang_at_toplevel, "\\!\\!", "Error: expected \"{\"."); +error!( + double_escaped_bang_at_toplevel, + "\\!\\!", "Error: expected \"{\"." +); +error!( + nothing_after_escape_inside_brackets, + "a { color: [\\", "Error: expected \"]\"." +);