diff --git a/yara-x/src/compiler/mod.rs b/yara-x/src/compiler/mod.rs index 94803acf2..d9c512ff3 100644 --- a/yara-x/src/compiler/mod.rs +++ b/yara-x/src/compiler/mod.rs @@ -1094,12 +1094,12 @@ impl<'a> Compiler<'a> { ), ); } else { - if matches!(leading.is_greedy(), Some(true)) { + if matches!(p.hir.is_greedy(), Some(true)) { flags.set(SubPatternFlags::Greedy); } prev_sub_pattern_id = self.process_regexp( - leading, + &p.hir, SubPattern::RegexpChainTail { chained_to: prev_sub_pattern_id, gap: p.gap.clone(), diff --git a/yara-x/src/tests/mod.rs b/yara-x/src/tests/mod.rs index 526791f47..c5e483971 100644 --- a/yara-x/src/tests/mod.rs +++ b/yara-x/src/tests/mod.rs @@ -438,6 +438,12 @@ fn hex_patterns() { pattern_true!(r#"{ 01 02 03 04 }"#, b"\x01\x02\x03\x04"); pattern_true!(r#"{ (01 02 03 04 | 05 06 07 08) }"#, b"\x01\x02\x03\x04"); pattern_match!(r#"{ 31 32 [-] 38 39 }"#, b"123456789", b"123456789"); + pattern_match!( + r#"{ 31 ?? 33 [-] 37 ?? 39 }"#, + b"123456789", + b"123456789" + ); + pattern_match!( r#"{ 31 32 [-] 33 34 [-] 38 39 }"#, b"123456789",