eea / odfpy

API for OpenDocument in Python
GNU General Public License v2.0
311 stars 64 forks source link

Strange meta crash saving doc. #105

Closed EliseyP closed 3 years ago

EliseyP commented 3 years ago

If we have some strange meta data in odt, f.e.: (it's really file on my archive, instead '\n' usual newline) --- meta.xml: -----------------------

\n \n \n \n \n \n + \n \n \n \n \n \n Serafim \n ... and so one --- meta.xml ----------------------- **OpenDocument.__replaceGenerator()** /in opendocument.py/ crash with AttributeError. I put code to try/except, and it work correctly. strings 575-578: ``` def __replaceGenerator(self): try: for m in self.meta.childNodes[:]: if m.qname == (METANS, u'generator'): self.meta.removeChild(m) self.meta.addElement(meta.Generator(text=TOOLSVERSION)) except AttributeError: pass ``` in childNodes we have excess Text elements: '\n\n\n\n\n\n' and try\exept let ignore this.
sorenroug commented 3 years ago

The 'except' clause doesn't replace the generator element if there is a text node in the XML file. I have committed another fix.