Skip to content

ZipFile does not supports Unicode Path Extra Field (0x7075) zip header field #86094

Closed

Description

@ivansorokintech
BPO 41928
Nosy @agiudiceandrea
PRs
  • bpo-41928: Add support for Unicode Path Extra Field in ZipFile #23736
  • Files
  • 23.zip
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2020-10-04.11:21:41.399>
    labels = ['type-feature', 'library', '3.10']
    title = 'ZipFile does not supports Unicode Path Extra Field (0x7075) zip header field'
    updated_at = <Date 2021-01-22.01:30:26.942>
    user = 'https://bugs.python.org/ivansorokintech'

    bugs.python.org fields:

    activity = <Date 2021-01-22.01:30:26.942>
    actor = 'andreaerdna'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2020-10-04.11:21:41.399>
    creator = 'ivan.sorokin.tech'
    dependencies = []
    files = ['49491']
    hgrepos = []
    issue_num = 41928
    keywords = ['patch']
    message_count = 3.0
    messages = ['377931', '377945', '385467']
    nosy_count = 2.0
    nosy_names = ['ivan.sorokin.tech', 'andreaerdna']
    pr_nums = ['23736']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue41928'
    versions = ['Python 3.10']

    Linked PRs

    Activity

    1. ivansorokintech commented on Oct 4, 2020

      ivansorokintechmannequin
      MannequinAuthor

      See attached sample. Well-known unzip command line tool lists its contents correctly:

      $ unzip -l 23.zip
      Archive:  23.zip
        Length      Date    Time    Name
      ---------  ---------- -----   

      81408  2012-10-23 19:03   Β' ΦΑΣΗ ΠΕ06 ΣΧΟΛΕΙΑ ΕΑΕΠ (ΙΝΤ).xls
      

      --------- -------
      81408 1 file

      But ZipFile lists the same file inside this archive as
      ü' öÇæå Åä06 æòÄèäêÇ äÇäÅ (êîÆ).xls

      It's because ZipFile completely ignores Unicode Path Extra Field (0x7075) zip header field.

      See .ZIP specification for details on this field meaning and usage:
      https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on Oct 4, 2020
    3. ivansorokintech commented on Oct 4, 2020

      ivansorokintechmannequin
      MannequinAuthor

      Grand unified algorithm to read filenames from zip files correctly:

      1. Do zip entry have «Unicode Path Extra Field» (0x7075)? Use it for file name.
      2. Is Unicode flag (0x800) set in «Flags» Field of zip entry? Assume «Filename» Field is in UTF-8.
      3. Do «HostOS» Field of zip entry have values of 0 (FAT) or 11 (NTFS)? Assume «Filename» Field is in OEM charset corresponding to system locale.
      4. Assume «Filename» Field is in UTF-8.

      p7zip with oemcp patch (https://github.com/unxed/oemcp/) uses exactly this method, and is able to process all zip files in my test set correctly (my test set contains several zips generated by different packers on windows, macos, linux, and by online services). The same algorithm should be used in any zip unpacker wishing to process non-latin filenames as gently as possible.

    4. agiudiceandrea commented on Jan 22, 2021

      agiudiceandreamannequin
      Mannequin

      I submitted more than a month ago a PR that adds support for Unicode Path Extra Field in ZipFile.
      The PR #23736 is awaiting a review in order to be merged.

    5. transferred this issue fromon Apr 10, 2022
    6. added a commit that references this issue on Apr 5, 2023
    7. added
      3.12only security fixes
      and removed on Apr 5, 2023
    8. added a commit that references this issue on Apr 8, 2023
    9. added a commit that references this issue on Apr 11, 2023
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.12only security fixesstdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions