Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Update filter-parser/src/value.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Clément Renault <clement@meilisearch.com>
  • Loading branch information
irevoire and Kerollmops authored Jan 10, 2022
1 parent 3c7ea1d commit 0fcde35
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions filter-parser/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,20 @@ fn quoted_by(quote: char, input: Span) -> IResult<Token> {
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 let Some((_, c)) = i.next() {
escaped |= c == quote;
} else {
return Err(nom::Err::Error(Error::new_from_kind(
input,
ErrorKind::MalformedValue,
)));
}
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 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((
Expand Down

0 comments on commit 0fcde35

Please sign in to comment.