Skip to content

Commit ee0a82f

Browse files
authored
fix matcher unwrap crash on unusual input with ASAN build (#93)
1 parent 8365964 commit ee0a82f

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,4 +1162,16 @@ mod tests {
11621162
use crate::canonicalize_and_process::canonicalize_pathname;
11631163
assert!(canonicalize_pathname("3�/..").is_ok());
11641164
}
1165+
1166+
#[test]
1167+
fn matcher_matches_doesnt_crash() {
1168+
let input = "(H\\PH)e:*) (emH\\<N)E*(elNH\\PH)e�{}?u";
1169+
let base = "example.com";
1170+
let base_url = Url::parse(base).ok();
1171+
let init =
1172+
UrlPatternInit::parse_constructor_string::<regex::Regex>(input, base_url);
1173+
let _ = init.and_then(|init_res| {
1174+
UrlPattern::<Regex>::parse(init_res, Default::default())
1175+
});
1176+
}
11651177
}

src/matcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<R: RegExp> Matcher<R> {
9494
Some(vec![Some(input)])
9595
}
9696
InnerMatcher::RegExp { regexp, .. } => {
97-
regexp.as_ref().unwrap().matches(input)
97+
regexp.as_ref().ok()?.matches(input)
9898
}
9999
}
100100
}

0 commit comments

Comments
 (0)