Skip to content

Commit

Permalink
https://github.com/sanluan/PublicCMS/issues/13
Browse files Browse the repository at this point in the history
Unsafe Unzip bug fix
  • Loading branch information
sanluan committed Jun 28, 2018
1 parent 5d6b25a commit f5e6eae
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,15 @@ public static void unzip(String zipFilePath, String targetPath, boolean overwrit
if (null != entryEnum) {
while (entryEnum.hasMoreElements()) {
ZipEntry zipEntry = entryEnum.nextElement();
String filePath = zipEntry.getName();
if (filePath.contains("..")) {
filePath = filePath.replace("..", BLANK);
}
if (zipEntry.isDirectory()) {
File dir = new File(targetPath + File.separator + zipEntry.getName());
File dir = new File(targetPath + File.separator + filePath);
dir.mkdirs();
} else {
File targetFile = new File(targetPath + File.separator + zipEntry.getName());
File targetFile = new File(targetPath + File.separator + filePath);
if (!targetFile.exists() || overwrite) {
targetFile.getParentFile().mkdirs();
try (InputStream inputStream = zipFile.getInputStream(zipEntry);
Expand Down

0 comments on commit f5e6eae

Please sign in to comment.