Skip to content

Zip file cannot be unzipped on Windows if the password contains a section sign #328

@barix

Description

@barix

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):

public class Zip4jUtil {
...
  public static byte[] convertCharArrayToByteArray(char[] charArray) {
    byte[] bytes = new byte[charArray.length];
    for (int i = 0; i < charArray.length; i++) {
      bytes[i] = (byte) charArray[i];
    }
    return bytes;
  }
...

convertCharArrayToByteArray("§".toCharArray()) without InternalZipConstants returns "�" and with InternalZipConstants "§".

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingresolved

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions