diff --git a/oletools/msodde.py b/oletools/msodde.py index c5b7bfb..90d8501 100644 --- a/oletools/msodde.py +++ b/oletools/msodde.py @@ -565,20 +565,21 @@ def process_docx(filepath, field_filter_mode=None): continue # have a TAG_W_P - elem = None for curr_elem in subs: # check if w:r; parse children to pull out first FLDCHAR/INSTRTEXT + elem = None if curr_elem.tag in TAG_W_R: for child in curr_elem: if child.tag in TAG_W_FLDCHAR or \ child.tag in TAG_W_INSTRTEXT: elem = child break + if elem is None: + continue # no fldchar or instrtext in this w:r else: elem = curr_elem if elem is None: - logging.warning('this should be an error condition') - continue + raise BadOOXML(filepath, 'Got "None"-Element from iter_xml') # check if FLDCHARTYPE and whether "begin" or "end" tag attrib_type = elem.attrib.get(ATTR_W_FLDCHARTYPE[0]) or \ diff --git a/oletools/olevba3.py b/oletools/olevba3.py index 2f83979..546b47b 100644 --- a/oletools/olevba3.py +++ b/oletools/olevba3.py @@ -2878,7 +2878,9 @@ class VBA_Parser(object): self.vba_code_all_modules = '' for (_, _, _, vba_code) in self.extract_all_macros(): #TODO: filter code? (each module) - self.vba_code_all_modules += vba_code.decode('utf-8', 'ignore') + '\n' + if isinstance(vba_code, bytes): + vba_code = vba_code.decode('utf-8', 'ignore') + self.vba_code_all_modules += vba_code + '\n' for (_, _, form_string) in self.extract_form_strings(): self.vba_code_all_modules += form_string.decode('utf-8', 'ignore') + '\n' # Analyze the whole code at once: