This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author garrison.taylor
Recipients garrison.taylor
Date 2021-01-29.20:28:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1611952128.43.0.663068649879.issue43066@roundup.psfhosted.org>
In-reply-to
Content
Currently the zipfile library allows you to create invalid zip files. The following code is an example:

from zipfile import ZipFile
import tempfile
temporary_file = tempfile.NamedTemporaryFile()
my_zip = ZipFile(temporary_file.name, 'w')
my_zip.writestr('/some_folder/some_file.txt', 'Some content')
my_zip.close()

The generated zipfile contains "/some_folder/some_file.txt". However, according to the specification for zip files, this is invalid. See below, from the .ZIP File Format Specification version 6.3.9:

       4.4.17.1 The name of the file, with optional relative path.
       The path stored MUST NOT contain a drive or
       device letter, or a leading slash.  All slashes
       MUST be forward slashes '/' as opposed to
       backwards slashes '\' for compatibility with Amiga
       and UNIX file systems etc.  If input came from standard
       input, there is no file name field.  

This is significant because the default Windows Explorer zip file extractor cannot handle zip files that contain a leading slash, producing an error that "The compressed (zipped) folder is invalid."
History
Date User Action Args
2021-01-29 20:28:48garrison.taylorsetrecipients: + garrison.taylor
2021-01-29 20:28:48garrison.taylorsetmessageid: <1611952128.43.0.663068649879.issue43066@roundup.psfhosted.org>
2021-01-29 20:28:48garrison.taylorlinkissue43066 messages
2021-01-29 20:28:48garrison.taylorcreate