Skip to content

Excess spaces at the end of files or repositorys are not handle when extracting zip files on Windows. #94018

@Rygone

Description

@Rygone

Bug report

Excess spaces at the end of files or repositorys are not handle when extracting zip files on Windows.
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Documents \\test.txt'

Can be tested with this Documents.zip
and this piece of code:

from zipfile import ZipFile
with ZipFile('Documents.zip', 'r') as zip:
    zip.extractall()

Fix proposal

cpython/Lib/zipfile.py : 1690

# remove end spaces
def remove_end_spaces(x):
    for c in x[::-1]:
        if(c == ' '): x = x[:-1]
        else: return x
arcname = (remove_end_spaces(x) for x in arcname)

Your environment

  • CPython versions tested on: python 3.9
  • Operating system and architecture: Windows 10 Professionnel 21H2 19044.1706

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowstype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy