-
Notifications
You must be signed in to change notification settings - Fork 313
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
Zip file cannot be unzipped on Windows if the password contains a section sign #328
Comments
Using non-ascii characters for passwords is in a grey zone as far as zip specification is concerned. Some tools convert passwords to utf8 and some don't. With the change that you linked, zip4j converts the password to utf8 by default, and I guess Windows doesn't, and that's why it works fine in your case when you revert the utf8 conversion. I added an option to I will include this in the next release |
Fixed in v2.11.0 released today |
This zip file is encrypted by "hun 焰", But it can not be decrypted by zip4j like this: public static void main(String[] args) {
byte[] readBuffer = new byte[4096];
Zip4jConfig zip4jConfig = new Zip4jConfig(StandardCharsets.UTF_8, 4096, false);
try (ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream("E:\\Code\\temp\\tmp\\test\\test_hun 焰.zip"), "hun 焰".toCharArray(), zip4jConfig)) {
while (zipInputStream.getNextEntry() != null) {
while (zipInputStream.read(readBuffer) != -1) {
}
}
System.out.println("success");
} catch (ZipException e) {
System.out.println("fail1");
} catch (IOException e) {
System.out.println("fail2");
} |
Hello,
when I create a zip file with a password that contains a section character (§), I cannot unzip that file with the same password when using 7-Zip 19.00 (x64) on Windows. When I use the command line
7z x out.zip
(p7zip Version 15.14.1) in cygwin or WinRar I was able to extract all files. I reverted the commit b69843a and was able to create and unzip a zip file with a password that contains a section character.I think the crucial code section is
Zip4jUtil#convertCharArrayToByteArray(char[])
. Code after reverting b69843a (was the only merge conflict):convertCharArrayToByteArray("§".toCharArray())
withoutInternalZipConstants
returns "�" and withInternalZipConstants
"§".The text was updated successfully, but these errors were encountered: