Skip to content

Commit 2b939aa

Browse files
committed
feat(zip): make it possible to skip header tests
1 parent ff64d0a commit 2b939aa

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,7 @@ public bool TestArchive(bool testData, TestStrategy strategy, ZipTestResultHandl
10841084
[Flags]
10851085
private enum HeaderTest
10861086
{
1087+
None = 0x0,
10871088
Extract = 0x01, // Check that this header represents an entry whose data can be extracted
10881089
Header = 0x02, // Check that this header contents are valid
10891090
}
@@ -3672,9 +3673,15 @@ private void ReadEntries()
36723673
/// </exception>
36733674
private long LocateEntry(ZipEntry entry)
36743675
{
3675-
return TestLocalHeader(entry, HeaderTest.Extract);
3676+
return TestLocalHeader(entry, SkipLocalEntryTestsOnLocate ? HeaderTest.None : HeaderTest.Extract);
36763677
}
36773678

3679+
/// <summary>
3680+
/// Skip the verification of the local header when reading an archive entry. Set this to attempt to read the
3681+
/// entries even if the headers should indicate that doing so would fail or produce an unexpected output.
3682+
/// </summary>
3683+
public bool SkipLocalEntryTestsOnLocate { get; set; } = false;
3684+
36783685
private Stream CreateAndInitDecryptionStream(Stream baseStream, ZipEntry entry)
36793686
{
36803687
CryptoStream result = null;

0 commit comments

Comments
 (0)