Skip to content
Open
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
9 changes: 7 additions & 2 deletions modules/core/src/com/alee/utils/ZipUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
Expand Down Expand Up @@ -115,8 +116,12 @@ public static void unzip ( @NotNull final File archive, @NotNull final File dst,
}
else
{
final File zipEntryFile = new File ( dst, entry.getName () );
if (!zipEntryFile.toPath ().normalize ().startsWith (dst.toPath ().normalize ())) {
throw new IOException ("Bad zip entry");
}
// Ensures that destination file and its folders exist
extractToFile = new File ( dst, entry.getName () );
extractToFile = zipEntryFile;
final File parent = FileUtils.getParent ( extractToFile );
if ( parent != null && parent.mkdirs () )
{
Expand Down Expand Up @@ -171,4 +176,4 @@ public static String getFileLocation ( @NotNull final ZipEntry zipEntry )
final String name = zipEntry.getName ();
return name.substring ( 0, name.lastIndexOf ( "/" ) + 1 );
}
}
}