aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs8
1 files changed, 7 insertions, 1 deletions
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<Box<dyn LogFilter>> {
// 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(