comparison MoinMoin/filter/application_vnd_sun_xml.py @ 5240:b2e96d4cac1c

OpenOffice/OpenDocument filters: catch UnicodeDecodeErrors (happens with password protected files)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 28 Oct 2009 22:35:33 +0100
parents ae8bf4c7d5a1
children
comparison
equal deleted inserted replaced
5239:90fae67c4cda 5240:b2e96d4cac1c
2 """ 2 """
3 MoinMoin - OpenOffice.org *.sx? Filter 3 MoinMoin - OpenOffice.org *.sx? Filter
4 4
5 Depends on: nothing (only python with zlib) 5 Depends on: nothing (only python with zlib)
6 6
7 @copyright: 2006 MoinMoin:ThomasWaldmann 7 @copyright: 2006-2009 MoinMoin:ThomasWaldmann
8 @license: GNU GPL, see COPYING for details. 8 @license: GNU GPL, see COPYING for details.
9 """ 9 """
10 10
11 import re, zipfile 11 import re, zipfile
12 12
22 zf.close() 22 zf.close()
23 data = " ".join(rx_stripxml.sub(" ", data).split()) 23 data = " ".join(rx_stripxml.sub(" ", data).split())
24 except (zipfile.BadZipfile, RuntimeError), err: 24 except (zipfile.BadZipfile, RuntimeError), err:
25 logging.error("%s [%s]" % (str(err), filename)) 25 logging.error("%s [%s]" % (str(err), filename))
26 data = "" 26 data = ""
27 return data.decode('utf-8') 27 try:
28 data = data.decode('utf-8')
29 except UnicodeDecodeError:
30 # protected with password? no valid OpenOffice file?
31 data = u''
32 return data
28 33