changeset 3017:2fb7b7a26690

wikiutil.url_unquote: try harder when decoding to unicode, avoid crashing (port from 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 06 Jan 2008 20:09:15 +0100
parents 5b17fc649925
children 5dfd26496da8
files MoinMoin/wikiutil.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/wikiutil.py	Sun Jan 06 20:07:19 2008 +0100
+++ b/MoinMoin/wikiutil.py	Sun Jan 06 20:09:15 2008 +0100
@@ -161,7 +161,10 @@
         s = s.encode(config.charset) # ascii would also work
     s = urllib.unquote(s)
     if want_unicode:
-        s = s.decode(config.charset)
+        try:
+            s = decodeUserInput(s, [config.charset, 'iso-8859-1', ]) # try hard
+        except UnicodeError:
+            s = s.decode('ascii', 'replace') # better than crashing
     return s
 
 def parseQueryString(qstr, want_unicode=True):