diff --git a/crates/protocol/src/archive.rs b/crates/protocol/src/archive.rs index 6a1a901..5f79dfe 100644 --- a/crates/protocol/src/archive.rs +++ b/crates/protocol/src/archive.rs @@ -52,7 +52,7 @@ impl ArchiveError { } } -/// Check one entry and return its path as plain components (no `.`, never empty). +/// Check one entry and return its path as plain components (no `.`; empty only for the root dir). pub fn check_entry(kind: EntryKind, path: &str, size: u64) -> Result, ArchiveError> { match kind { EntryKind::File | EntryKind::Dir => {} @@ -78,7 +78,9 @@ pub fn check_entry(kind: EntryKind, path: &str, size: u64) -> Result c => parts.push(c.to_owned()), } } - if parts.is_empty() { + // The release's own root (`./`, as `tar -C dir -czf x .` writes it) names nothing: allowed for a + // directory, refused for anything else. + if parts.is_empty() && kind != EntryKind::Dir { return Err(ArchiveError::Path); } Ok(parts)