From 3f7a935932c888d624cf8e6bb4a3ccf300b9345f Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Fri, 10 Jun 2016 17:05:22 +0200 Subject: [PATCH] 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 --- files/unarchive.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/files/unarchive.py b/files/unarchive.py index 6492af60633..af9891a008f 100644 --- a/files/unarchive.py +++ b/files/unarchive.py @@ -312,13 +312,16 @@ class ZipArchive(object): for line in old_out.splitlines(): change = False - pcs = line.split() - if len(pcs) != 8: continue + pcs = line.split(None, 7) + + # 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] permstr = pcs[0][1:10] - version = pcs[0][1] - ostype = pcs[0][2] + version = pcs[1] + ostype = pcs[2] size = int(pcs[3]) path = pcs[7]