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
8 changes: 8 additions & 0 deletions SabreTools.Serialization/Wrappers/PKZIP.Extraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ public bool Extract(string outputDirectory, bool lookForHeader, bool includeDebu
// If the entry is partial due to an incomplete multi-part archive, skip it
if (!entry.IsComplete)
continue;

// If the entry is password-protected, skip it
if (entry.IsEncrypted)
{
if (includeDebug) Console.WriteLine($"File {entry.Key} in zip is password-protected!");

continue;
}

// Ensure directory separators are consistent
string filename = entry.Key;
Expand Down
27 changes: 24 additions & 3 deletions SabreTools.Serialization/Wrappers/RAR.Extraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,25 @@ public bool Extract(string outputDirectory, bool lookForHeader, bool includeDebu
continue;

if (firstFile)
{
firstFile = false;
else
continue;
}

if (entry.IsSolid)
{
isSolid = entry.IsSolid;
break;
// If the RAR is solid and the first entry is password-protected, you won't be able to
// extract the rest of the entries anyway, so just return early.
if (entry.IsEncrypted)
{
if (includeDebug) Console.WriteLine("RAR is password-protected!");
return false;
}

isSolid = true;
}

break;
}
catch (Exception ex)
{
Expand Down Expand Up @@ -215,6 +228,14 @@ private static bool ExtractNonSolid(RarArchive rarFile, string outDir, bool incl
// If we have a partial entry due to an incomplete multi-part archive, skip it
if (!entry.IsComplete)
continue;

// If the entry is password-protected, skip it
if (entry.IsEncrypted)
{
if (includeDebug) Console.WriteLine($"File {entry.Key} in RAR is password-protected!");

continue;
}

// Ensure directory separators are consistent
string filename = entry.Key;
Expand Down
27 changes: 24 additions & 3 deletions SabreTools.Serialization/Wrappers/SevenZip.Extraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,25 @@ public bool Extract(string outputDirectory, bool lookForHeader, bool includeDebu
continue;

if (firstFile)
{
firstFile = false;
else
continue;
}

if (entry.IsSolid)
{
isSolid = entry.IsSolid;
break;
// If the 7z is solid and the first entry is password-protected, you won't be able to
// extract the rest of the entries anyway, so just return early.
if (entry.IsEncrypted)
{
if (includeDebug) Console.WriteLine("7z is password-protected!");
return false;
}

isSolid = true;
}

break;
}
catch (Exception ex)
{
Expand Down Expand Up @@ -183,6 +196,14 @@ private static bool ExtractNonSolid(SevenZipArchive sevenZip, string outputDirec
// If we have a partial entry due to an incomplete multi-part archive, skip it
if (!entry.IsComplete)
continue;

// If the entry is password-protected, skip it
if (entry.IsEncrypted)
{
if (includeDebug) Console.WriteLine($"File {entry.Key} in 7z is password-protected!");

continue;
}

// Ensure directory separators are consistent
string filename = entry.Key;
Expand Down