From a5ba31bfa9b9f31b8309e42f0a4f24716b298b31 Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Wed, 18 Apr 2018 09:33:49 +0200 Subject: [PATCH] msodde: Determine when error condition actually is one --- oletools/msodde.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 \ -- libgit2 0.21.4