Skip to content

Commit

Permalink
fix: issue in with regexp that are split into multiple regexps
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed Jul 24, 2023
1 parent df172d7 commit c0ab821
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions yara-x/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 6 additions & 0 deletions yara-x/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit c0ab821

Please # to comment.