Skip to content

Commit 1b19687

Browse files
committed
fix: unicode on exactly index 7 should not panic
1 parent eae7202 commit 1b19687

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
@@ -427,4 +427,11 @@ mod tests {
427427
assert!(uri.label.is_none());
428428
assert!(uri.message.is_none());
429429
}
430+
431+
#[test]
432+
fn bad_unicode_scheme() {
433+
let input = "bitcoinö:1andreas3batLhQa2FawWjeyjCqyBzypd";
434+
let uri = input.parse::<Uri<'_, _>>();
435+
assert!(uri.is_err());
436+
}
430437
}

0 commit comments

Comments
 (0)