Commit 6e069d5fd28c98ba2e349096bd47fbde5568909f

Authored by Christian Herdtweck
1 parent 5222ef66

ftguess: Add XPS type

Showing 1 changed file with 15 additions and 2 deletions
oletools/ftguess.py
... ... @@ -166,6 +166,7 @@ class FTYPE(object):
166 166 EXCEL2007_XLTM = 'Excel2007_XLTM'
167 167 EXCEL2007_XLSB = 'Excel2007_XLSB'
168 168 # TODO: XLSB, DOCM, PPTM, PPSX, PPSM, ...
  169 + XPS = 'XPS'
169 170 RTF = 'RTF'
170 171 HTML = 'HTML'
171 172 PDF = 'PDF'
... ... @@ -203,7 +204,7 @@ class APP(object):
203 204 MSPROJECT = 'MS Project'
204 205 MSOFFICE = 'MS Office' # when the exact app is unknown
205 206 ZIP_ARCHIVER = 'Any Zip Archiver'
206   - WINDOWS = 'Windows' # for Windows executables
  207 + WINDOWS = 'Windows' # for Windows executables and XPS
207 208 UNKNOWN = 'Unknown Application'
208 209  
209 210 # FTYPE_NAME = {
... ... @@ -222,6 +223,8 @@ ATTR_REL_TARGET = 'Target'
222 223 URL_REL_OFFICEDOC = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
223 224 # For "strict" OpenXML formats, the URL is different:
224 225 URL_REL_OFFICEDOC_STRICT = 'http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument'
  226 +# Url for xps files
  227 +URL_REL_XPS = 'http://schemas.microsoft.com/xps/2005/06/fixedrepresentation'
225 228 # Namespaces and tags for OpenXML parsing`- Content-types file:
226 229 NS_CONTENT_TYPES = '{http://schemas.openxmlformats.org/package/2006/content-types}'
227 230 TAG_CTYPES_DEFAULT = NS_CONTENT_TYPES + 'Default'
... ... @@ -395,7 +398,7 @@ class FType_Generic_OpenXML(FType_Base):
395 398 for elem_rel in elem_rels.iter(tag=TAG_REL):
396 399 rel_type = elem_rel.get(ATTR_REL_TYPE)
397 400 log.debug('Relationship: type=%s target=%s' % (rel_type, elem_rel.get(ATTR_REL_TARGET)))
398   - if rel_type in (URL_REL_OFFICEDOC, URL_REL_OFFICEDOC_STRICT):
  401 + if rel_type in (URL_REL_OFFICEDOC, URL_REL_OFFICEDOC_STRICT, URL_REL_XPS):
399 402 # TODO: is it useful to distinguish normal and strict OpenXML?
400 403 main_part = elem_rel.get(ATTR_REL_TARGET)
401 404 # TODO: raise anomaly if there are more than one rel with type office doc
... ... @@ -559,6 +562,14 @@ class FType_Excel2007_XLSM (FTYpe_Excel2007):
559 562 content_types = ('application/vnd.ms-excel.sheet.macroEnabled.12',)
560 563 PUID = 'fmt/445'
561 564  
  565 +class FType_XPS(FType_Generic_OpenXML):
  566 + application = APP.WINDOWS
  567 + filetype = FTYPE.XPS
  568 + name = 'XPS'
  569 + longname = 'Fixed-Page Document (.xps)',
  570 + extensions = ['xps']
  571 +
  572 +
562 573 # TODO: for PPT, check for stream 'PowerPoint Document'
563 574 # TODO: for Visio, check for stream 'VisioDocument'
564 575  
... ... @@ -583,6 +594,8 @@ openxml_ftypes = {
583 594 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml': FType_Excel2007_XLSX,
584 595 'application/vnd.ms-excel.sheet.macroEnabled.main+xml': FType_Excel2007_XLSM,
585 596 'application/vnd.ms-excel.sheet.binary.macroEnabled.main': None,
  597 + # XPS
  598 + 'application/vnd.ms-package.xps-fixeddocumentsequence+xml': FType_XPS,
586 599 }
587 600  
588 601  
... ...