Skip to content

Commit 0258de1

Browse files
committed
fix matcher unwrap crash on unusual input with ASAN build
1 parent 579d8a7 commit 0258de1

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/lib.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,4 +1162,28 @@ 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+
1171+
// let string_or_init = quirks::StringOrInit::String(input.to_owned());
1172+
// // let pattern_init = quirks::process_construct_pattern_input(
1173+
// // string_or_init,
1174+
// // Some("example.com"),
1175+
// // );
1176+
// let base_url = unsafe { base.as_ref() }
1177+
// .map(|x| x.to_utf8().into_owned())
1178+
// .as_deref()
1179+
// .map(Url::parse);
1180+
// let init = UrlPatternInit::parse_constructor_string::<regex::Regex>(
1181+
// input, base_url,
1182+
// );
1183+
//
1184+
// let options = None;
1185+
// let _ = pattern_init.and_then(|init_res| {
1186+
// UrlPattern::<Regex>::parse(init_res, options.unwrap_or_default())
1187+
// });
1188+
// }
11651189
}

src/matcher.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ 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().unwrap().matches(input)
98+
regexp.as_ref().ok()?.matches(input)
9899
}
99100
}
100101
}

0 commit comments

Comments
 (0)