Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions crates/uv-client/src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ impl SimpleHtml {
debug!("{err}");
Hashes::default()
}
Err(
err
@ (HashError::UnsupportedHashAlgorithm(..) | HashError::NonUtf8(..)),
) => {
Err(err @ HashError::UnsupportedHashAlgorithm(..)) => {
// If the URL references a hash, but it's unsupported, error.
return Err(err.into());
}
Expand Down
15 changes: 4 additions & 11 deletions crates/uv-pypi-types/src/simple_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ impl Hashes {

match name {
"md5" => {
let md5 = std::str::from_utf8(value.as_bytes())?;
let md5 = md5.to_owned().into_boxed_str();
let md5 = value.to_owned().into_boxed_str();
Ok(Hashes {
md5: Some(md5),
sha256: None,
Expand All @@ -202,8 +201,7 @@ impl Hashes {
})
}
"sha256" => {
let sha256 = std::str::from_utf8(value.as_bytes())?;
let sha256 = sha256.to_owned().into_boxed_str();
let sha256 = value.to_owned().into_boxed_str();
Ok(Hashes {
md5: None,
sha256: Some(sha256),
Expand All @@ -212,8 +210,7 @@ impl Hashes {
})
}
"sha384" => {
let sha384 = std::str::from_utf8(value.as_bytes())?;
let sha384 = sha384.to_owned().into_boxed_str();
let sha384 = value.to_owned().into_boxed_str();
Ok(Hashes {
md5: None,
sha256: None,
Expand All @@ -222,8 +219,7 @@ impl Hashes {
})
}
"sha512" => {
let sha512 = std::str::from_utf8(value.as_bytes())?;
let sha512 = sha512.to_owned().into_boxed_str();
let sha512 = value.to_owned().into_boxed_str();
Ok(Hashes {
md5: None,
sha256: None,
Expand Down Expand Up @@ -419,9 +415,6 @@ pub enum HashError {
"Unsupported hash algorithm (expected one of: `md5`, `sha256`, `sha384`, or `sha512`) on: `{0}`"
)]
UnsupportedHashAlgorithm(String),

#[error("Non-UTF-8 hash digest")]
NonUtf8(#[from] std::str::Utf8Error),
}

#[cfg(test)]
Expand Down
Loading