diff --git a/src/de.rs b/src/de.rs index 7080130..a5942fd 100644 --- a/src/de.rs +++ b/src/de.rs @@ -25,7 +25,7 @@ impl<'a, T: DeserializeParams<'a>> Uri<'a, bitcoin::address::NetworkUnchecked, T return Err(Error::Uri(UriError(UriErrorInner::TooShort))); } - if !string[..SCHEME.len()].eq_ignore_ascii_case(SCHEME) { + if !string.get(..SCHEME.len()).is_some_and(|s| s.eq_ignore_ascii_case(SCHEME)) { return Err(Error::Uri(UriError(UriErrorInner::InvalidScheme))); } diff --git a/src/lib.rs b/src/lib.rs index 5f699ff..b60eba5 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -479,4 +479,11 @@ mod tests { assert!(uri.message.is_none()); assert_eq!(uri.to_string(), "bitcoin:1andreas3batLhQa2FawWjeyjCqyBzypd?label=foo"); } + + #[test] + fn bad_unicode_scheme() { + let input = "bitcoinö:1andreas3batLhQa2FawWjeyjCqyBzypd"; + let uri = input.parse::>(); + assert!(uri.is_err()); + } }