Subject: | Junk Added to Empty Files |
Date: | Tue, 24 May 2011 10:18:15 -0700 |
To: | bug-archive-zip [...] rt.cpan.org |
From: | "David E. Wheeler" <dwheeler [...] cpan.org> |
The attached zip file was created for a sample Python project using this command:
python setup.py sdist --format=gztar,zip
It includes a file, __init__.py, of size zero. Using UnZip 5.52 on Mac OS X, it works great:
% unzip python.zip
Archive: python.zip
inflating: Foo-0.2.0/setup.cfg
inflating: Foo-0.2.0/PKG-INFO
inflating: Foo-0.2.0/setup.py
inflating: Foo-0.2.0/bar/__init__.py
inflating: Foo-0.2.0/bar/baz.py
inflating: Foo-0.2.0/Foo.egg-info/SOURCES.txt
inflating: Foo-0.2.0/Foo.egg-info/PKG-INFO
inflating: Foo-0.2.0/Foo.egg-info/requires.txt
inflating: Foo-0.2.0/Foo.egg-info/dependency_links.txt
inflating: Foo-0.2.0/Foo.egg-info/top_level.txt
Now let's let Archive::Zip rewrite the zip file:
perl -MArchive::Zip -E 'my $z = Archive::Zip->new; $z->read(shift); $z->writeToFileNamed("out.zip");' python.zip
All we're doing is reading the zip file in and writing it out again. But that breaks the empty file:
unzip out.zip
Archive: out.zip
inflating: Foo-0.2.0/setup.cfg
inflating: Foo-0.2.0/PKG-INFO
inflating: Foo-0.2.0/setup.py
Foo-0.2.0/bar/__init__.py: ucsize 0 <> csize 2 for STORED entry
continuing with "compressed" size value
extracting: Foo-0.2.0/bar/__init__.py bad CRC 1a6cd7b3 (should be 00000000)
inflating: Foo-0.2.0/bar/baz.py
inflating: Foo-0.2.0/Foo.egg-info/SOURCES.txt
inflating: Foo-0.2.0/Foo.egg-info/PKG-INFO
inflating: Foo-0.2.0/Foo.egg-info/requires.txt
inflating: Foo-0.2.0/Foo.egg-info/dependency_links.txt
inflating: Foo-0.2.0/Foo.egg-info/top_level.txt
And sure enough, __init__.py is now two bytes long:
Foo-0.2.0/bar/__init__.py
PK
So Archive::Zip is shoving that "PK" in there. It ought not to do that, I think. I'll see if I can figure out why it's doing this and submit a patch.
Best,
David
Message body not shown because it is not plain text.