diff --git a/src/main/java/net/lingala/zip4j/tasks/AbstractExtractFileTask.java b/src/main/java/net/lingala/zip4j/tasks/AbstractExtractFileTask.java index 80fa365c..0169ef4f 100644 --- a/src/main/java/net/lingala/zip4j/tasks/AbstractExtractFileTask.java +++ b/src/main/java/net/lingala/zip4j/tasks/AbstractExtractFileTask.java @@ -18,6 +18,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.regex.Matcher; import static net.lingala.zip4j.util.InternalZipConstants.FILE_SEPARATOR; @@ -173,7 +174,12 @@ private File determineOutputFile(FileHeader fileHeader, String outputPath, Strin if (Zip4jUtil.isStringNotNullAndNotEmpty(newFileName)) { outputFileName = newFileName; } - return new File(outputPath + FILE_SEPARATOR + outputFileName); + return new File(outputPath, getFileNameWithSystemFileSeparators(outputFileName)); + } + + private String getFileNameWithSystemFileSeparators(String fileNameToReplace) { + String formattedFileName = fileNameToReplace.replaceAll(":\\\\", "_"); + return formattedFileName.replaceAll("[/\\\\]", Matcher.quoteReplacement(FILE_SEPARATOR)); } @Override