Skip to content
Snippets Groups Projects
Commit d61fb7f7 authored by Alex Marchant's avatar Alex Marchant Committed by jvoisin
Browse files

Wait to remove elements until they are all processed

parent 1aed4ff2
No related branches found
No related tags found
No related merge requests found
Pipeline #258663 failed
......@@ -283,9 +283,15 @@ class MSOfficeParser(ZipParser):
for children in element.iterfind('./*'):
elements_ins.append((element, position, children))
break
for (element, position, children) in elements_ins:
parent_map[element].insert(position, children)
parent_map[element].remove(element)
# the list can sometimes contain duplicate elements, so don't remove
# until all children have been processed
for (element, position, children) in elements_ins:
if element in parent_map[element]:
parent_map[element].remove(element)
tree.write(full_path, xml_declaration=True, encoding='utf-8')
return True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment