From 0fcde35a20a933963f867b0abb2e471a729dd822 Mon Sep 17 00:00:00 2001 From: Tamo Date: Mon, 10 Jan 2022 15:53:44 +0100 Subject: [PATCH] Update filter-parser/src/value.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Renault --- filter-parser/src/value.rs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/filter-parser/src/value.rs b/filter-parser/src/value.rs index ec7c93656..84dd21902 100644 --- a/filter-parser/src/value.rs +++ b/filter-parser/src/value.rs @@ -26,24 +26,20 @@ fn quoted_by(quote: char, input: Span) -> IResult { let mut i = input.iter_indices(); while let Some((idx, c)) = i.next() { - match c { - c if c == quote => { - let (rem, output) = input.take_split(idx); - return Ok((rem, Token::new(output, escaped.then(|| unescape(output, quote))))); + if c == quote { + let (rem, output) = input.take_split(idx); + return Ok((rem, Token::new(output, escaped.then(|| unescape(output, quote))))); + } else if c == '\\' { + if let Some((_, c)) = i.next() { + escaped |= c == quote; + } else { + return Err(nom::Err::Error(Error::new_from_kind( + input, + ErrorKind::MalformedValue, + ))); } - '\\' => { - if let Some((_, c)) = i.next() { - escaped |= c == quote; - } else { - return Err(nom::Err::Error(Error::new_from_kind( - input, - ErrorKind::MalformedValue, - ))); - } - } - // if it was preceeded by a `\` or if it was anything else we can continue to advance - _ => (), } + // if it was preceeded by a `\` or if it was anything else we can continue to advance } Ok((