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

zipfile: read after write fails for non-ascii files #85240

Closed
serhiy-storchaka opened this issue Jun 21, 2020 · 4 comments
Closed

zipfile: read after write fails for non-ascii files #85240

serhiy-storchaka opened this issue Jun 21, 2020 · 4 comments
Assignees
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 41068
Nosy @serhiy-storchaka, @miss-islington
PRs
  • bpo-41068: Fix read after write in zipfile for non-ASCII files names. #21040
  • [3.8] bpo-41068: Fix read after write in zipfile for non-ASCII files names. (GH-21040) #21048
  • [3.7] bpo-41068: Fix read after write in zipfile for non-ASCII files names. (GH-21040) #21049
  • [3.9] bpo-41068: Fix read after write in zipfile for non-ASCII files names. (GH-21040) #21050
  • 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 = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2020-06-22.09:34:31.118>
    created_at = <Date 2020-06-21.20:08:04.227>
    labels = ['3.8', 'type-bug', 'library', '3.9', '3.10']
    title = 'zipfile: read after write fails for non-ascii files'
    updated_at = <Date 2020-06-28.13:01:56.700>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2020-06-28.13:01:56.700>
    actor = 'ned.deily'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2020-06-22.09:34:31.118>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2020-06-21.20:08:04.227>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41068
    keywords = ['patch']
    message_count = 4.0
    messages = ['372018', '372047', '372051', '372053']
    nosy_count = 2.0
    nosy_names = ['serhiy.storchaka', 'miss-islington']
    pr_nums = ['21040', '21048', '21049', '21050']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue41068'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @serhiy-storchaka
    Copy link
    Member Author

    When open a ZIP archive, write a file with non-ascii name in it, and, not closing the archive, read that file back, it fails:

    >>> import zipfile
    >>> with zipfile.ZipFile('test.zip', 'w') as zf:
    ...     zf.writestr('йцукен', '')
    ...     zf.read('йцукен')
    ... 
    Traceback (most recent call last):
      File "<stdin>", line 3, in <module>
      File "/usr/lib/python3.8/zipfile.py", line 1440, in read
        with self.open(name, "r", pwd) as fp:
      File "/usr/lib/python3.8/zipfile.py", line 1521, in open
        raise BadZipFile(
    zipfile.BadZipFile: File name in directory 'йцукен' and header b'\xd0\xb9\xd1\x86\xd1\x83\xd0\xba\xd0\xb5\xd0\xbd' differ.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life 3.10 only security fixes 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jun 21, 2020
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset 36ff513 by Serhiy Storchaka in branch 'master':
    bpo-41068: Fix read after write in zipfile for non-ASCII files names. (GH-21040)
    36ff513

    @miss-islington
    Copy link
    Contributor

    New changeset d7f37d1 by Miss Islington (bot) in branch '3.8':
    bpo-41068: Fix read after write in zipfile for non-ASCII files names. (GH-21040)
    d7f37d1

    @miss-islington
    Copy link
    Contributor

    New changeset c916c48 by Miss Islington (bot) in branch '3.9':
    bpo-41068: Fix read after write in zipfile for non-ASCII files names. (GH-21040)
    c916c48

    @ned-deily ned-deily removed 3.7 (EOL) end of life labels Jun 28, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants