Skip to content

Commit 76244b1

Browse files
authored
Merge pull request #4 from lsunsi/master
fix: unicode on exactly index 7 should not panic
2 parents a02bdb5 + 1b19687 commit 76244b1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/de.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl<'a, T: DeserializeParams<'a>> Uri<'a, bitcoin::address::NetworkUnchecked, T
2525
return Err(Error::Uri(UriError(UriErrorInner::TooShort)));
2626
}
2727

28-
if !string[..SCHEME.len()].eq_ignore_ascii_case(SCHEME) {
28+
if !string.get(..SCHEME.len()).is_some_and(|s| s.eq_ignore_ascii_case(SCHEME)) {
2929
return Err(Error::Uri(UriError(UriErrorInner::InvalidScheme)));
3030
}
3131

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,4 +479,11 @@ mod tests {
479479
assert!(uri.message.is_none());
480480
assert_eq!(uri.to_string(), "bitcoin:1andreas3batLhQa2FawWjeyjCqyBzypd?label=foo");
481481
}
482+
483+
#[test]
484+
fn bad_unicode_scheme() {
485+
let input = "bitcoinö:1andreas3batLhQa2FawWjeyjCqyBzypd";
486+
let uri = input.parse::<Uri<'_, _>>();
487+
assert!(uri.is_err());
488+
}
482489
}

0 commit comments

Comments
 (0)