Improve the unzip output scraping (#3819)

* Improve the unzip output scraping

Ensure we capture the complete file (also when it includes spaces).
Drop lines that do not conform (in length) to what we expect (e.g. header/footer).

This fixes #3813

* Fix how split() works
This commit is contained in:
Dag Wieers 2016-06-10 17:05:22 +02:00 committed by Matt Clay
parent 17985f9917
commit c6fb3ceb85

View file

@ -312,13 +312,16 @@ class ZipArchive(object):
for line in old_out.splitlines(): for line in old_out.splitlines():
change = False change = False
pcs = line.split() pcs = line.split(None, 7)
if len(pcs) != 8: continue
# Check first and seventh field in order to skip header/footer
if len(pcs[0]) != 7 and len(pcs[0]) != 10: continue
if len(pcs[6]) != 15: continue
ztype = pcs[0][0] ztype = pcs[0][0]
permstr = pcs[0][1:10] permstr = pcs[0][1:10]
version = pcs[0][1] version = pcs[1]
ostype = pcs[0][2] ostype = pcs[2]
size = int(pcs[3]) size = int(pcs[3])
path = pcs[7] path = pcs[7]