Commit 676b344677d34ae48a2a33414dde83929522057c

Authored by decalage2
2 parents 9d064030 3d75da3e

Merge remote-tracking branch 'origin/master'

oletools/msodde.py
@@ -565,20 +565,21 @@ def process_docx(filepath, field_filter_mode=None): @@ -565,20 +565,21 @@ def process_docx(filepath, field_filter_mode=None):
565 continue 565 continue
566 566
567 # have a TAG_W_P 567 # have a TAG_W_P
568 - elem = None  
569 for curr_elem in subs: 568 for curr_elem in subs:
570 # check if w:r; parse children to pull out first FLDCHAR/INSTRTEXT 569 # check if w:r; parse children to pull out first FLDCHAR/INSTRTEXT
  570 + elem = None
571 if curr_elem.tag in TAG_W_R: 571 if curr_elem.tag in TAG_W_R:
572 for child in curr_elem: 572 for child in curr_elem:
573 if child.tag in TAG_W_FLDCHAR or \ 573 if child.tag in TAG_W_FLDCHAR or \
574 child.tag in TAG_W_INSTRTEXT: 574 child.tag in TAG_W_INSTRTEXT:
575 elem = child 575 elem = child
576 break 576 break
  577 + if elem is None:
  578 + continue # no fldchar or instrtext in this w:r
577 else: 579 else:
578 elem = curr_elem 580 elem = curr_elem
579 if elem is None: 581 if elem is None:
580 - logging.warning('this should be an error condition')  
581 - continue 582 + raise BadOOXML(filepath, 'Got "None"-Element from iter_xml')
582 583
583 # check if FLDCHARTYPE and whether "begin" or "end" tag 584 # check if FLDCHARTYPE and whether "begin" or "end" tag
584 attrib_type = elem.attrib.get(ATTR_W_FLDCHARTYPE[0]) or \ 585 attrib_type = elem.attrib.get(ATTR_W_FLDCHARTYPE[0]) or \
oletools/olevba3.py
@@ -2878,7 +2878,9 @@ class VBA_Parser(object): @@ -2878,7 +2878,9 @@ class VBA_Parser(object):
2878 self.vba_code_all_modules = '' 2878 self.vba_code_all_modules = ''
2879 for (_, _, _, vba_code) in self.extract_all_macros(): 2879 for (_, _, _, vba_code) in self.extract_all_macros():
2880 #TODO: filter code? (each module) 2880 #TODO: filter code? (each module)
2881 - self.vba_code_all_modules += vba_code.decode('utf-8', 'ignore') + '\n' 2881 + if isinstance(vba_code, bytes):
  2882 + vba_code = vba_code.decode('utf-8', 'ignore')
  2883 + self.vba_code_all_modules += vba_code + '\n'
2882 for (_, _, form_string) in self.extract_form_strings(): 2884 for (_, _, form_string) in self.extract_form_strings():
2883 self.vba_code_all_modules += form_string.decode('utf-8', 'ignore') + '\n' 2885 self.vba_code_all_modules += form_string.decode('utf-8', 'ignore') + '\n'
2884 # Analyze the whole code at once: 2886 # Analyze the whole code at once: