Commit 56e394732394b5469b7b5d67c3587e9be8e17d74

Authored by Christian Herdtweck
1 parent 7f9c4f03

msodde: remove another unnecessary warning that messed up json

Showing 1 changed file with 24 additions and 16 deletions
oletools/msodde.py
@@ -730,23 +730,31 @@ def process_xlsx(filepath, filed_filter_mode=None): @@ -730,23 +730,31 @@ def process_xlsx(filepath, filed_filter_mode=None):
730 730
731 # binary parts, e.g. contained in .xlsb 731 # binary parts, e.g. contained in .xlsb
732 for subfile, content_type, handle in parser.iter_non_xml(): 732 for subfile, content_type, handle in parser.iter_non_xml():
733 - if content_type == 'application/vnd.openxmlformats-officedocument.' + \  
734 - 'spreadsheetml.printerSettings':  
735 - continue # printer settings  
736 - if not content_type.startswith('application/vnd.ms-excel.') and \  
737 - not content_type.startswith('application/vnd.ms-office.'): # pylint: disable=bad-indentation  
738 - logging.warning('Unexpected content type: ' + content_type)  
739 - # try parsing anyway  
740 -  
741 - logging.info('Parsing non-xml subfile {0} with content type {1}' 733 + try:
  734 + logging.info('Parsing non-xml subfile {0} with content type {1}'
  735 + .format(subfile, content_type))
  736 + for record in xls_parser.parse_xlsb_part(handle, content_type, subfile):
  737 + logging.debug('{0}: {1}'.format(subfile, record))
  738 + if isinstance(record, xls_parser.XlsbBeginSupBook) and \
  739 + record.link_type == \
  740 + xls_parser.XlsbBeginSupBook.LINK_TYPE_DDE:
  741 + dde_links.append('DDE-Link ' + record.string1 + ' ' +
  742 + record.string2)
  743 + except Exception:
  744 + if content_type.startswith('application/vnd.ms-excel.') or \
  745 + content_type.startswith('application/vnd.ms-office.'): # pylint: disable=bad-indentation
  746 + # should really be able to parse these either as xml or records
  747 + log_func = logging.warning
  748 + elif content_type.startswith('image/') or content_type == \
  749 + 'application/vnd.openxmlformats-officedocument.' + \
  750 + 'spreadsheetml.printerSettings':
  751 + # understandable that these are not record-base
  752 + log_func = logging.debug
  753 + else: # default
  754 + log_func = logging.info
  755 + log_func('Failed to parse {0} of content type {1}'
742 .format(subfile, content_type)) 756 .format(subfile, content_type))
743 - for record in xls_parser.parse_xlsb_part(handle, content_type, subfile):  
744 - logging.debug('{0}: {1}'.format(subfile, record))  
745 - if isinstance(record, xls_parser.XlsbBeginSupBook) and \  
746 - record.link_type == \  
747 - xls_parser.XlsbBeginSupBook.LINK_TYPE_DDE:  
748 - dde_links.append('DDE-Link ' + record.string1 + ' ' +  
749 - record.string2) 757 + # in any case: continue with next
750 758
751 return u'\n'.join(dde_links) 759 return u'\n'.join(dde_links)
752 760