Skip to content

Commit

Permalink
Merge pull request #4 from lsunsi/master
Browse files Browse the repository at this point in the history
fix: unicode on exactly index 7 should not panic
  • Loading branch information
DanGould authored Dec 2, 2024
2 parents a02bdb5 + 1b19687 commit 76244b1
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()).is_some_and(|s| s.eq_ignore_ascii_case(SCHEME)) {
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 @@ -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::<Uri<'_, _>>();
assert!(uri.is_err());
}
}

0 comments on commit 76244b1

Please sign in to comment.