Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In centos7.3, the folder is parsed into a file name when it is uncompressed. #81

Closed
langjxk opened this issue Oct 8, 2019 · 13 comments
Closed
Assignees
Labels
bug Something isn't working resolved

Comments

@langjxk
Copy link

langjxk commented Oct 8, 2019

In centos7.3, the folder is parsed into a file name when it is uncompressed. For example: "home/myzip/ziptest.zip" should be extracted to "home/myzip/ziptest/test/mytest1.zip", but it is incorrectly Unzip it to "home/myzip/ziptest\test\mytest1.zip", where "ziptest\test\mytest1.zip" becomes the file name

@srikanth-lingala srikanth-lingala self-assigned this Oct 8, 2019
@srikanth-lingala srikanth-lingala added the bug Something isn't working label Oct 8, 2019
@srikanth-lingala
Copy link
Owner

I just made a quick fix and made a SNAPSHOT release (fix is not yet on github).
Can you please check with version 2.2.3-SNAPSHOT and see if it works fine for you? If yes, I will make push the fix and make a release.

@langjxk
Copy link
Author

langjxk commented Oct 9, 2019

I just made a quick fix and made a SNAPSHOT release (fix is not yet on github).
Can you please check with version 2.2.3-SNAPSHOT and see if it works fine for you? If yes, I will make push the fix and make a release.

How do I get 2.2.3-SNAPSHOT? I can't get it from maven.

@srikanth-lingala
Copy link
Owner

srikanth-lingala commented Oct 9, 2019

Please use this in your pom. It is also totally fine if you just use the snapshotRepository part of it:

<distributionManagement>
    <snapshotRepository>
        <id>ossrh</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
        <id>ossrh</id>
        <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
</distributionManagement>

@langjxk
Copy link
Author

langjxk commented Oct 9, 2019

The bug is still not resolved. In version 1.3.2, it can be solved as follows:

if(File.separator.equals("/")){ List<FileHeader> headerListModify = zFile.getFileHeaders(); for (FileHeader fileHeader : headerListModify) { if (StringUtils.isNotBlank(fileHeader.getFileName())) { fileHeader.setFileName(fileHeader.getFileName().replaceAll("\\\\",File.separator)); } } }

However, the following verification has been added to the 2.x version, which makes it impossible to continue using this method

`private void verifyNextEntry(ZipInputStream zipInputStream, FileHeader fileHeader) throws IOException {
LocalFileHeader localFileHeader = zipInputStream.getNextEntry(fileHeader);

if (localFileHeader == null) {
    throw new ZipException("Could not read corresponding local file header for file header: "+ fileHeader.getFileName());
}

if (!fileHeader.getFileName().equals(localFileHeader.getFileName())) {
    throw new ZipException("File header and local file header mismatch");
}

}`

@srikanth-lingala
Copy link
Owner

With this snapshot version, do you get any error message or do you still get the output file names as home/myzip/ziptest\test\mytest1.zip?

@langjxk
Copy link
Author

langjxk commented Oct 10, 2019

The output file name is still "home/myzip/ziptest\test\mytest1.zip".

@srikanth-lingala
Copy link
Owner

Can you try with 2.2.3.1-SNAPSHOT?

@langjxk
Copy link
Author

langjxk commented Oct 12, 2019

2.2.3.1-SNAPSHOT still has bugs. In centos7.3, the folder will not be created when decompressing. Once the multi-level directory is extracted, it will report an error: "ZipException!java.io.FileNotFoundException". For example: "net.lingala.zip4j.exception.ZipException: java.io.FileNotFoundException: home/myzip/ziptest/dir1/test.txt
At net.lingala.zip4j.tasks.AsyncZipTask.performTaskWithErrorHandling(AsyncZipTask.java:49)
At net.lingala.zip4j.tasks.AsyncZipTask.execute(AsyncZipTask.java:36)
At net.lingala.zip4j.ZipFile.extractAll(ZipFile.java:437)"
In windows, another error will be reported: "net.lingala.zip4j.exception.ZipException: java.lang.IllegalArgumentException: character to be escaped is missing
At net.lingala.zip4j.tasks.AsyncZipTask.performTaskWithErrorHandling(AsyncZipTask.java:49)
At net.lingala.zip4j.tasks.AsyncZipTask.execute(AsyncZipTask.java:36)
At net.lingala.zip4j.ZipFile.extractAll(ZipFile.java:437)"

@srikanth-lingala
Copy link
Owner

I made some more changes. Can you please try again with 2.2.3.3-SNAPSHOT?

@langjxk
Copy link
Author

langjxk commented Oct 12, 2019

2.2.3.3-SNAPSHOT is already available in centos7.3, but it is still the last bug in win10: "net.lingala.zip4j.exception.ZipException: java.lang.IllegalArgumentException: character to be escaped is missing
At net.lingala.zip4j.tasks.AsyncZipTask.performTaskWithErrorHandling(AsyncZipTask.java:49)
At net.lingala.zip4j.tasks.AsyncZipTask.execute(AsyncZipTask.java:36)
At net.lingala.zip4j.ZipFile.extractAll(ZipFile.java:437)"

@srikanth-lingala
Copy link
Owner

Can you please try again with 2.2.3.4-SNAPSHOT?

@langjxk
Copy link
Author

langjxk commented Oct 14, 2019

After testing, 2.2.3.4-SNAPSHOT found no bugs in centos7.3 and win10. thanks.

@srikanth-lingala
Copy link
Owner

srikanth-lingala commented Oct 19, 2019

Fixed in v2.2.3 released today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved
Projects
None yet
Development

No branches or pull requests

2 participants