diff --git a/engine/src/ast/field_expr.rs b/engine/src/ast/field_expr.rs index 88e1061e..298a7c05 100644 --- a/engine/src/ast/field_expr.rs +++ b/engine/src/ast/field_expr.rs @@ -1085,6 +1085,12 @@ mod tests { #[test] fn test_ip_compare() { + assert!( + FilterParser::new(&SCHEME) + .lex_as::("ip.addr == 10.10.10.10") + .is_ok() + ); + let expr = assert_ok!( FilterParser::new(&SCHEME).lex_as("ip.addr <= 10:20:30:40:50:60:70:80"), ComparisonExpr { @@ -1138,6 +1144,18 @@ mod tests { #[test] fn test_bytes_compare() { + assert_err!( + FilterParser::new(&SCHEME).lex_as::("http.host == 10.10.10.10"), + LexErrorKind::ExpectedName("byte separator"), + "." + ); + + assert!( + FilterParser::new(&SCHEME) + .lex_as::(r#"http.host == "10.10.10.10""#) + .is_ok() + ); + // just check that parsing doesn't conflict with IPv6 { let expr = assert_ok!( diff --git a/engine/src/rhs_types/bytes.rs b/engine/src/rhs_types/bytes.rs index 45e51b59..a83b8f18 100644 --- a/engine/src/rhs_types/bytes.rs +++ b/engine/src/rhs_types/bytes.rs @@ -178,7 +178,6 @@ fn write_char(vec: &mut Vec, c: char) { enum ByteSeparator { Colon, Dash, - Dot, } impl Lex<'_> for ByteSeparator { @@ -187,7 +186,6 @@ impl Lex<'_> for ByteSeparator { match sep { ":" => Ok((ByteSeparator::Colon, rest)), "-" => Ok((ByteSeparator::Dash, rest)), - "." => Ok((ByteSeparator::Dot, rest)), _ => Err((LexErrorKind::ExpectedName("byte separator"), sep)), } } @@ -345,11 +343,17 @@ mod test { #[test] fn test() { assert_ok!( - BytesExpr::lex("01:2e:f3-77.12;"), + BytesExpr::lex("01:2e:f3-77:12;"), BytesExpr::from(vec![0x01, 0x2E, 0xF3, 0x77, 0x12]), ";" ); + assert_err!( + BytesExpr::lex("10.10.10.10"), + LexErrorKind::ExpectedName("byte separator"), + "." + ); + assert_ok!( BytesExpr::lex(r#""s\\t\"r\x0A\000t""#), BytesExpr::from("s\\t\"r\n\0t".to_owned())