mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-16 22:14:30 +00:00
Fix format container Clippy diagnostics
This commit is contained in:
@@ -82,6 +82,8 @@ pub struct PartDigest {
|
||||
pub digest: [u8; 32],
|
||||
}
|
||||
|
||||
type TrackedParts = (fn(&str) -> bool, Vec<PartDigest>);
|
||||
|
||||
/// A container being written.
|
||||
pub struct Writer {
|
||||
zip: craft_zip::Writer,
|
||||
@@ -90,7 +92,7 @@ pub struct Writer {
|
||||
resolved: usize,
|
||||
limits: Limits,
|
||||
/// Which written parts to record for a signature, and the records so far.
|
||||
tracked: Option<(fn(&str) -> bool, Vec<PartDigest>)>,
|
||||
tracked: Option<TrackedParts>,
|
||||
}
|
||||
|
||||
impl Writer {
|
||||
@@ -111,7 +113,7 @@ impl Writer {
|
||||
|
||||
/// The container's bytes.
|
||||
pub fn finish(self) -> Result<Vec<u8>, FormatError> {
|
||||
Ok(self.zip.finish().map_err(invalid)?)
|
||||
self.zip.finish().map_err(invalid)
|
||||
}
|
||||
|
||||
/// Add a part, compressed or stored. A name already written is written once.
|
||||
@@ -206,11 +208,13 @@ impl Reader {
|
||||
// no path components that are "." or "..", and no duplicates.
|
||||
let mut name_set = BTreeSet::new();
|
||||
for entry_idx in 0..archive.len() {
|
||||
if let Ok(Some(name)) = archive.entry_name(entry_idx) {
|
||||
if name.is_empty() || name.contains('\\') || name.split('/').any(|c| c.is_empty() || c == "." || c == "..") || !name_set.insert(name)
|
||||
{
|
||||
return Err(invalid("duplicate or invalid archive entry"));
|
||||
}
|
||||
if let Ok(Some(name)) = archive.entry_name(entry_idx)
|
||||
&& (name.is_empty()
|
||||
|| name.contains('\\')
|
||||
|| name.split('/').any(|c| c.is_empty() || c == "." || c == "..")
|
||||
|| !name_set.insert(name))
|
||||
{
|
||||
return Err(invalid("duplicate or invalid archive entry"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user