Skip to content

Commit

Permalink
fix: unicode on exactly index 7 should not panic
Browse files Browse the repository at this point in the history
  • Loading branch information
lsunsi committed Sep 25, 2024
1 parent eae7202 commit 863c708
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()).filter(|s| s.eq_ignore_ascii_case(SCHEME)).is_none() {
return Err(Error::Uri(UriError(UriErrorInner::InvalidScheme)));
}

Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,4 +427,11 @@ mod tests {
assert!(uri.label.is_none());
assert!(uri.message.is_none());
}

#[test]
fn bad_unicode_scheme() {
let input = "bitcoinö:1andreas3batLhQa2FawWjeyjCqyBzypd";
let uri = input.parse::<Uri<'_, _>>();
assert!(uri.is_err());
}
}

0 comments on commit 863c708

Please sign in to comment.