Skip to content

Commit c0a032a

Browse files
committed
Don't prefilter on regexes where the cleaning step didn't work
1 parent e91dc9f commit c0a032a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/pyrosimple/util/matching.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,11 @@ def pre_filter_eq(self) -> str:
348348
else:
349349
needle = self.CLEAN_PRE_VAL_RE.sub(" ", self._value)
350350
split_needle = self.SPLIT_PRE_GLOB_RE.split(needle)
351+
# If the cleaning of the needle did not succeed and we still
352+
# have regex-y values, don't prefilter
353+
print(needle)
354+
if any(metachar in needle for metachar in r'{}[]\\|()'):
355+
return ""
351356
# Grab the longest needle available from the array
352357
needle = list(sorted(split_needle, key=len))[-1]
353358

src/tests/test_matching.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ def test_matcher_fail(matcher, item):
203203
('name="arch linux"', 'string.contains_i=$d.name=,"arch linux"'),
204204
("name=/arch/", 'string.contains_i=$d.name=,"arch"'),
205205
("name=/(arch|foo)k+/", 'string.contains_i=$d.name=,"k"'),
206+
("name=/((arch|ubuntu)|foo)k+/", ''),
206207
("name=ARCH", 'string.contains_i=$d.name=,"ARCH"'),
207208
("size<1G", "less=d.size_bytes=,value=1073741824"),
208209
("is_complete=no", "equal=d.complete=,value=0"),

0 commit comments

Comments
 (0)