Commit 3a002837e9386a7934c4fbfb199f2d69b404bfcf

Authored by Etienne Stalmans
1 parent 7bcabd99

Use constants for TAG_W_R and TAG_W_P instead of constructing string each time

Showing 1 changed file with 4 additions and 2 deletions
oletools/msodde.py
... ... @@ -85,6 +85,8 @@ NO_QUOTES = False
85 85 TAG_W_INSTRTEXT = '{%s}instrText' % NS_WORD
86 86 TAG_W_FLDSIMPLE = '{%s}fldSimple' % NS_WORD
87 87 TAG_W_FLDCHAR = '{%s}fldChar' % NS_WORD
  88 +TAG_W_P = "{%s}p" % NS_WORD
  89 +TAG_W_R = "{%s}r" % NS_WORD
88 90 ATTR_W_INSTR = '{%s}instr' % NS_WORD
89 91 ATTR_W_FLDCHARTYPE = '{%s}fldCharType' % NS_WORD
90 92  
... ... @@ -118,11 +120,11 @@ def process_file(filepath):
118 120 # fldChar can be in either a w:r element or floating alone in the w:p
119 121 # escape DDE if quoted etc
120 122 # (each is a chunk of a DDE link)
121   - for subs in root.iter("{%s}p"%NS_WORD):
  123 + for subs in root.iter(TAG_W_P):
122 124 level = 0
123 125 for e in subs:
124 126 #check if w:r and if it is parse children elements to pull out the first FLDCHAR or INSTRTEXT
125   - if e.tag == "{%s}r"%NS_WORD:
  127 + if e.tag == TAG_W_R:
126 128 for child in e:
127 129 if child.tag == TAG_W_FLDCHAR or child.tag == TAG_W_INSTRTEXT:
128 130 elem = child
... ...