diff 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
line wrap: on
line diff
--- a/MoinMoin/filter/application_vnd_sun_xml.py	Wed Oct 28 19:17:36 2009 +0100
+++ b/MoinMoin/filter/application_vnd_sun_xml.py	Wed Oct 28 22:35:33 2009 +0100
@@ -4,7 +4,7 @@
 
     Depends on: nothing (only python with zlib)
 
-    @copyright: 2006 MoinMoin:ThomasWaldmann
+    @copyright: 2006-2009 MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
 
@@ -24,5 +24,10 @@
     except (zipfile.BadZipfile, RuntimeError), err:
         logging.error("%s [%s]" % (str(err), filename))
         data = ""
-    return data.decode('utf-8')
+    try:
+        data = data.decode('utf-8')
+    except UnicodeDecodeError:
+        # protected with password? no valid OpenOffice file?
+        data = u''
+    return data