Detect path encoding for compatibility - #374
Conversation
|
@weichsel Any chance you can look at this pull request? |
|
@weichsel I pushed a commit to fix the CI issues, could you take another look? |
|
Hi tang3w,
|
|
Attaching the hex view of the sample test.zip if it helps: @weichsel Does it mean we have to add support for "Extended Language Encoding Extra Field" first? Is the content
|
|
I just had another look at "Appendix D". As far as I understand it now, this can only be used to provide an alternate, UTF-8 encoded version of the path (vs. providing info about the encoding - as I initially thought). So there is no spec-compliant way to encode paths in |
|
Hey @weichsel, I extracted one of the entries using HexFriend:
It does seem to include the utf-8 encoded file name as I can decode the file name with the test script below: # the Extra Field bytes of a ZIP file entry
extra_fields = "01A3DBF325E4BFA1E993B6E8A784E7ABA0E3809432303235E38095323734E58FB7EFBC88E99984E4BBB6EFBC895F546573742E646F6378"
data = bytes.fromhex(extra_fields)
utf8_bytes = data[5:] # Skip CRC32 bytes for testing
print(utf8_bytes.decode("utf-8")) # Output "信银规章〔2025〕274号(附件)_Test.docx" as expectedThen seems like it's a missing feature for ZIPFoundation to utilize the extra field to get the expected path name? |
|
Thanks for looking into this! Could it be that your archive uses some Info-ZIP extensions, like those mentioned in section 4.6.9 of the App Note? Or perhaps another proprietary ZIP extension? Also, do you have the ability to control how the archive is created? If the path can be decoded in a way that matches the spec, I’m happy to add that. I’m a bit hesitant about using heuristics, as they might affect existing users or not work the same way on all platforms. |
It seems to be - the identifier is 0x7075:
Unfortunately no, we don't have the ability to control how the zip file is created - it's totally up to the users to choose their own software to create the archive.
I understand. How about add something to let users opt in the heuristics then (e.g., allow users to pass in a list of encodings for detect) so existing users won't be impacted by the change?
@weichsel That would be great and appreciated! Is there a rough timeline? |
I don't have the capacity to add that myself at the moment. But I can have a look at a PR that considers the Info-ZIP header when decoding paths. |


Fixes #373
Changes proposed in this PR
FileManager.unzipItemis called without specifying thepathEncoding, andcentralDirectoryStructure.usesUTF8PathEncodingis false.Tests performed
All existing unit tests are passed
Further info for the reviewer
N/A
Open Issues
N/A