Commit a5ba31bfa9b9f31b8309e42f0a4f24716b298b31
1 parent
40342031
msodde: Determine when error condition actually is one
msodde would sometimes complain that something should be an error condition. Determined that most of these are not and raise proper error for those that really are an error.
Showing
1 changed file
with
4 additions
and
3 deletions
oletools/msodde.py
| ... | ... | @@ -565,20 +565,21 @@ def process_docx(filepath, field_filter_mode=None): |
| 565 | 565 | continue |
| 566 | 566 | |
| 567 | 567 | # have a TAG_W_P |
| 568 | - elem = None | |
| 569 | 568 | for curr_elem in subs: |
| 570 | 569 | # check if w:r; parse children to pull out first FLDCHAR/INSTRTEXT |
| 570 | + elem = None | |
| 571 | 571 | if curr_elem.tag in TAG_W_R: |
| 572 | 572 | for child in curr_elem: |
| 573 | 573 | if child.tag in TAG_W_FLDCHAR or \ |
| 574 | 574 | child.tag in TAG_W_INSTRTEXT: |
| 575 | 575 | elem = child |
| 576 | 576 | break |
| 577 | + if elem is None: | |
| 578 | + continue # no fldchar or instrtext in this w:r | |
| 577 | 579 | else: |
| 578 | 580 | elem = curr_elem |
| 579 | 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 | 584 | # check if FLDCHARTYPE and whether "begin" or "end" tag |
| 584 | 585 | attrib_type = elem.attrib.get(ATTR_W_FLDCHARTYPE[0]) or \ | ... | ... |