aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel <kingdread@gmx.de>2020-06-12 14:25:17 +0200
committerDaniel <kingdread@gmx.de>2020-06-12 14:25:17 +0200
commit3d4ac61f9d8506ef82301772fe41c75d0f19e5a4 (patch)
tree848ff454f2d0b156b697ca53a8ebb82576154895 /src
parenta8481afdac21b8b846d5fe159678972a879b11c0 (diff)
downloadraidgrep-3d4ac61f9d8506ef82301772fe41c75d0f19e5a4.tar.gz
raidgrep-3d4ac61f9d8506ef82301772fe41c75d0f19e5a4.tar.bz2
raidgrep-3d4ac61f9d8506ef82301772fe41c75d0f19e5a4.zip
report invalid filters that are valid regexes
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(