Open
Description
The following test case currently fails:
#[test]
fn valid_invalid_regex() {
let filters = vec![
String::from(r#"/^https:\/\/b\.com/"#),
String::from(r#"/^\=/"#),
];
let engine = Engine::from_rules_debug(&filters, FilterFormat::Standard);
assert!(engine.check_network_urls("https://b.com", "https://c.com", "script").matched);
}
The first filter works correctly when isolated, but as soon as the second filter is added, it no longer matches any requests.
It appears that this is due to the fact that the second rule is an incorrectly formatted regex (the =
character does not need to be escaped). Regex rules are lazily compiled, so this issue is not caught immediately. Later on, the regexes get compiled into an AnyOf
regex rule, but the entire rule is invalid because of the presence of the second rule and it produces a CompiledRegex::RegexParsingError
.
Either at parsing or compile time, these filters should be evaluated for validity and removed if necessary.