Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuzzing #84

Merged
merged 7 commits into from Apr 6, 2020

allow for escaping unicode characters in css selectors

  • Loading branch information
AndriusA committed Mar 30, 2020
commit 7dde6bdccde68c8c7b760c55dfdfcd37a5b2c9e2
@@ -532,7 +532,7 @@ fn key_from_selector(selector: &str) -> Result<String, CosmeticFilterError> {
beginning = location.end();
// Unwrap is safe because there is a capture group specified in the regex
let capture = capture.get(1).unwrap().as_str();
if capture.len() == 1 {
if capture.chars().count() == 1 { // Check number of unicode characters rather than byte length
key += capture;
} else {
// This u32 conversion can overflow
@@ -176,3 +176,22 @@ fn detect_filter_type(filter: &str) -> FilterType {
// Everything else is a network filter
FilterType::Network
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn parse_filter_failed_fuzz_1() {
let input = "Ѥ";
let result = parse_filter(input, true, true, true);
assert!(result.is_ok());
}

#[test]
fn parse_filter_failed_fuzz_2() {
assert!(parse_filter(r#"###\\\00DB \008D"#, true, true, true).is_ok());
assert!(parse_filter(r#"###\Û"#, true, true, true).is_ok());
}

}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.