From 3a002837e9386a7934c4fbfb199f2d69b404bfcf Mon Sep 17 00:00:00 2001 From: Etienne Stalmans Date: Tue, 24 Oct 2017 11:23:49 +0200 Subject: [PATCH] Use constants for TAG_W_R and TAG_W_P instead of constructing string each time --- oletools/msodde.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/oletools/msodde.py b/oletools/msodde.py index deff8da..b0f91a9 100644 --- a/oletools/msodde.py +++ b/oletools/msodde.py @@ -85,6 +85,8 @@ NO_QUOTES = False TAG_W_INSTRTEXT = '{%s}instrText' % NS_WORD TAG_W_FLDSIMPLE = '{%s}fldSimple' % NS_WORD TAG_W_FLDCHAR = '{%s}fldChar' % NS_WORD +TAG_W_P = "{%s}p" % NS_WORD +TAG_W_R = "{%s}r" % NS_WORD ATTR_W_INSTR = '{%s}instr' % NS_WORD ATTR_W_FLDCHARTYPE = '{%s}fldCharType' % NS_WORD @@ -118,11 +120,11 @@ def process_file(filepath): # fldChar can be in either a w:r element or floating alone in the w:p # escape DDE if quoted etc # (each is a chunk of a DDE link) - for subs in root.iter("{%s}p"%NS_WORD): + for subs in root.iter(TAG_W_P): level = 0 for e in subs: #check if w:r and if it is parse children elements to pull out the first FLDCHAR or INSTRTEXT - if e.tag == "{%s}r"%NS_WORD: + if e.tag == TAG_W_R: for child in e: if child.tag == TAG_W_FLDCHAR or child.tag == TAG_W_INSTRTEXT: elem = child -- libgit2 0.21.4