ISibboI / evalexpr

A powerful expression evaluation crate 🦀.
GNU Affero General Public License v3.0
320 stars 52 forks source link

BUG: String parsing needs check ending quote #141

Closed gaoqiangz closed 1 year ago

gaoqiangz commented 1 year ago

String parsing needs check ending quote:

https://github.com/ISibboI/evalexpr/blob/bcc6a07879c983a4ef34e762626639ead23146ba/src/token/mod.rs#L252-L260

Test case:

let expr = r#"ident == "broken string"#;
gaoqiangz commented 1 year ago

Consider fix solution:

 while let Some(c) = iter.next() {
    match c {
        '"' => return Ok(PartialToken::Token(Token::String(result))),
        '\\' => result.push(parse_escape_sequence(&mut iter)?),
        c => result.push(c),
    }
}

Err(EvalexprError::UnmatchDoubleQuote)
ISibboI commented 1 year ago

Thanks for the report! I'll try out your fix.