Skip to content

Commit

Permalink
#363 Avoid replacing Windows file name separator
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanth-lingala committed Oct 19, 2021
1 parent 2ec68db commit ec78cea
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
10 changes: 0 additions & 10 deletions src/main/java/net/lingala/zip4j/headers/HeaderReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,6 @@ private CentralDirectory readCentralDirectory(RandomAccessFile zip4jRaf, RawIO r
byte[] fileNameBuff = new byte[fileNameLength];
zip4jRaf.readFully(fileNameBuff);
String fileName = decodeStringWithCharset(fileNameBuff, fileHeader.isFileNameUTF8Encoded(), charset);

if (fileName.contains(":\\")) {
fileName = fileName.substring(fileName.indexOf(":\\") + 2);
}

fileHeader.setFileName(fileName);
} else {
fileHeader.setFileName(null);
Expand Down Expand Up @@ -560,11 +555,6 @@ public LocalFileHeader readLocalFileHeader(InputStream inputStream, Charset char
readFully(inputStream, fileNameBuf);

String fileName = decodeStringWithCharset(fileNameBuf, localFileHeader.isFileNameUTF8Encoded(), charset);

if (fileName.contains(":" + System.getProperty("file.separator"))) {
fileName = fileName.substring(fileName.indexOf(":" + System.getProperty("file.separator")) + 2);
}

localFileHeader.setFileName(fileName);
localFileHeader.setDirectory(fileName.endsWith("/") || fileName.endsWith("\\"));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private File determineOutputFile(FileHeader fileHeader, String outputPath, Strin
outputFileName = newFileName;
} else {
// replace all slashes with file separator
outputFileName = getFileNameWithSystemFileSeparators(fileHeader.getFileName());
outputFileName = fileHeader.getFileName();
}

return new File(outputPath + FILE_SEPARATOR + outputFileName);
Expand Down

0 comments on commit ec78cea

Please sign in to comment.