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
11 changes: 3 additions & 8 deletions src/SharpCompress/Common/Zip/ZipFilePart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,12 @@ protected Stream CreateDecompressionStream(Stream stream, ZipCompressionMethod m
{
case ZipCompressionMethod.None:
{
if (stream is ReadOnlySubStream)
if (Header.CompressedSize is 0)
{
return stream;
return new DataDescriptorStream(stream);
}

if (Header.CompressedSize > 0)
{
return new ReadOnlySubStream(stream, Header.CompressedSize);
}

return new DataDescriptorStream(stream);
return stream;
}
case ZipCompressionMethod.Shrink:
{
Expand Down
17 changes: 17 additions & 0 deletions tests/SharpCompress.Test/Zip/ZipReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,21 @@ public void Zip_Uncompressed_64bit()

Assert.Equal(4, x);
}

[Fact]
public void Zip_Uncompressed_Encrypted_Read()
{
using var archive = ArchiveFactory.Open(
Path.Combine(TEST_ARCHIVES_PATH, "Zip.none.encrypted.zip"),
new ReaderOptions { Password = "test" }
);
using var reader = archive.ExtractAllEntries();
reader.MoveToNextEntry();
Assert.Equal("first.txt", reader.Entry.Key);
Assert.Equal(199, reader.Entry.Size);
reader.OpenEntryStream().Dispose();
reader.MoveToNextEntry();
Assert.Equal("second.txt", reader.Entry.Key);
Assert.Equal(197, reader.Entry.Size);
}
}
Binary file added tests/TestArchives/Archives/Zip.none.encrypted.zip
Binary file not shown.
Loading