summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2014-01-31 03:54:28 +0000
committerjvoisin2014-01-31 03:54:28 +0000
commit173449009769ce86493a179acb9c66c87125dce3 (patch)
tree8cc035901c9cc254370e74514c2f9a7dcee1b48c
parent1ca20db6741dabfbad567aa20bee92069a5ef5c7 (diff)
Fix office-format handling by the GUI
-rw-r--r--MAT/archive.py10
-rw-r--r--MAT/office.py5
-rwxr-xr-xmat-gui10
3 files changed, 19 insertions, 6 deletions
diff --git a/MAT/archive.py b/MAT/archive.py
index 3c6a139..62f4ca7 100644
--- a/MAT/archive.py
+++ b/MAT/archive.py
@@ -39,7 +39,7 @@ class GenericArchiveStripper(parser.GenericParser):
39 mat.secure_remove(path_file) 39 mat.secure_remove(path_file)
40 shutil.rmtree(self.tempdir) 40 shutil.rmtree(self.tempdir)
41 41
42 def is_clean(self, list_unsupported): 42 def is_clean(self, list_unsupported=False):
43 ''' Virtual method to check for harmul metadata 43 ''' Virtual method to check for harmul metadata
44 ''' 44 '''
45 raise NotImplementedError 45 raise NotImplementedError
@@ -312,6 +312,14 @@ class TarStripper(GenericArchiveStripper):
312 return metadata 312 return metadata
313 313
314 314
315class TerminalZipStripper(ZipStripper):
316 ''' Represent a terminal level archive.
317 This type of archive can not contain nested archives.
318 It is used for formats like docx, which are basically
319 ziped xml.
320 '''
321
322
315class GzipStripper(TarStripper): 323class GzipStripper(TarStripper):
316 ''' Represent a tar.gz archive 324 ''' Represent a tar.gz archive
317 ''' 325 '''
diff --git a/MAT/office.py b/MAT/office.py
index 97405b3..e4b9567 100644
--- a/MAT/office.py
+++ b/MAT/office.py
@@ -1,4 +1,5 @@
1''' Care about office's formats 1''' Care about office's formats
2
2''' 3'''
3 4
4import logging 5import logging
@@ -19,7 +20,7 @@ import parser
19import archive 20import archive
20 21
21 22
22class OpenDocumentStripper(archive.ZipStripper): 23class OpenDocumentStripper(archive.TerminalZipStripper):
23 ''' An open document file is a zip, with xml file into. 24 ''' An open document file is a zip, with xml file into.
24 The one that interest us is meta.xml 25 The one that interest us is meta.xml
25 ''' 26 '''
@@ -68,7 +69,7 @@ class OpenDocumentStripper(archive.ZipStripper):
68 return False 69 return False
69 70
70 71
71class OpenXmlStripper(archive.ZipStripper): 72class OpenXmlStripper(archive.TerminalZipStripper):
72 ''' Represent an office openxml document, which is like 73 ''' Represent an office openxml document, which is like
73 an opendocument format, with some tricky stuff added. 74 an opendocument format, with some tricky stuff added.
74 It contains mostly xml, but can have media blobs, crap, ... 75 It contains mostly xml, but can have media blobs, crap, ...
diff --git a/mat-gui b/mat-gui
index d5c1815..4785d82 100755
--- a/mat-gui
+++ b/mat-gui
@@ -409,14 +409,18 @@ non-anonymised) file to output archive'))
409 msg = _('Cleaning %s') % self.liststore[line][1].decode('utf-8', 'replace') 409 msg = _('Cleaning %s') % self.liststore[line][1].decode('utf-8', 'replace')
410 logging.info(msg) 410 logging.info(msg)
411 self.statusbar.push(0, msg) 411 self.statusbar.push(0, msg)
412 if isinstance(self.liststore[line][0].file, archive.GenericArchiveStripper): 412 is_archive = isinstance(self.liststore[line][0].file, archive.GenericArchiveStripper)
413 list_to_add = [] 413 is_terminal = isinstance(self.liststore[line][0].file, archive.TerminalZipStripper)
414 list_to_add = []
415 if is_archive and not is_terminal:
414 unsupported_list = self.liststore[line][0].file.list_unsupported() 416 unsupported_list = self.liststore[line][0].file.list_unsupported()
415 if type(unsupported_list) == list and unsupported_list: 417 if type(unsupported_list) == list and unsupported_list:
416 logging.debug("Unsupported list: %s" % unsupported_list) 418 logging.debug("Unsupported list: %s" % unsupported_list)
417 filename = os.path.basename(self.liststore[line][0].file.filename) 419 filename = os.path.basename(self.liststore[line][0].file.filename)
418 list_to_add = self.__popup_archive(filename, unsupported_list) 420 list_to_add = self.__popup_archive(filename, unsupported_list)
419 if self.liststore[line][0].file.remove_all(whitelist=list_to_add): 421 if self.liststore[line][0].file.remove_all(whitelist=list_to_add):
422 self.liststore[line][2] = _('Clean')
423 elif self.liststore[line][0].file.remove_all():
420 self.liststore[line][2] = _('Clean') 424 self.liststore[line][2] = _('Clean')
421 yield True 425 yield True
422 self.statusbar.push(0, _('Ready')) 426 self.statusbar.push(0, _('Ready'))