From 3d4ac61f9d8506ef82301772fe41c75d0f19e5a4 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 12 Jun 2020 14:25:17 +0200 Subject: report invalid filters that are valid regexes --- src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 133bd2d..674d128 100644 --- a/src/main.rs +++ b/src/main.rs @@ -129,10 +129,16 @@ impl Opt { fn build_filter(&self) -> Result> { // As a shortcut, we allow only the regular expression to be given, to retain the behaviour // before the filter changes. + + // Special characters that when present will prevent the filter to be interpreted as a + // regex. This is to ensure that errors are properly reported on invalid filterlines + // instead of being swallowed because the filter was taken as a (valid) regex: + const SPECIAL_CHARS: &[char] = &['-', '(', ')', ':', '<', '>', '=']; + if self.expression.len() == 1 { let line = &self.expression[0]; let maybe_filter = build_filter(line); - if maybe_filter.is_err() && !line.starts_with('-') { + if maybe_filter.is_err() && !line.contains(SPECIAL_CHARS) { let maybe_regex = Regex::new(line); if let Ok(rgx) = maybe_regex { let filter = filters::player::any( -- cgit v1.2.3