From fd0fbc7934cb3997a055b620c8af473126f88de8 Mon Sep 17 00:00:00 2001 From: Mees Delzenne Date: Tue, 17 Sep 2024 19:33:22 +0200 Subject: [PATCH] Fix inf loop in parser (#4803) --- core/src/syn/parser/idiom.rs | 2 ++ core/src/syn/parser/test/mod.rs | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/core/src/syn/parser/idiom.rs b/core/src/syn/parser/idiom.rs index 852f69a6..14d428da 100644 --- a/core/src/syn/parser/idiom.rs +++ b/core/src/syn/parser/idiom.rs @@ -185,6 +185,8 @@ impl Parser<'_> { if let Some(x) = self.parse_graph_idiom(ctx, &mut res, Dir::Both).await? { return Ok(x); } + } else { + break; } } t!("..") => { diff --git a/core/src/syn/parser/test/mod.rs b/core/src/syn/parser/test/mod.rs index a1e12218..9c69db00 100644 --- a/core/src/syn/parser/test/mod.rs +++ b/core/src/syn/parser/test/mod.rs @@ -47,6 +47,16 @@ fn glued_identifiers() { assert_eq!(res, expected); } +#[test] +fn less_then_idiom() { + let src = r#" + if ($param.foo < 2){ + return 1 + } + "#; + test_parse!(parse_query, src).unwrap(); +} + #[test] fn escaped_params() { let src = r#"LET $⟨R-_fYU8Wa31kg7tz0JI6Kme⟩ = 5;