diff options
author | Daniel <kingdread@gmx.de> | 2020-06-12 14:25:17 +0200 |
---|---|---|
committer | Daniel <kingdread@gmx.de> | 2020-06-12 14:25:17 +0200 |
commit | 3d4ac61f9d8506ef82301772fe41c75d0f19e5a4 (patch) | |
tree | 848ff454f2d0b156b697ca53a8ebb82576154895 /src/main.rs | |
parent | a8481afdac21b8b846d5fe159678972a879b11c0 (diff) | |
download | raidgrep-3d4ac61f9d8506ef82301772fe41c75d0f19e5a4.tar.gz raidgrep-3d4ac61f9d8506ef82301772fe41c75d0f19e5a4.tar.bz2 raidgrep-3d4ac61f9d8506ef82301772fe41c75d0f19e5a4.zip |
report invalid filters that are valid regexes
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 8 |
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( |