Description
User Preferences crash on save with:
File "/srv/moin/code/1.9/MoinMoin/userprefs/prefs.py", line 136, in _save_user_prefs request.user.editor_default = wikiutil.clean_input(form.get('editor_default', self.cfg.editor_default)) File "/srv/moin/code/1.9/MoinMoin/wikiutil.py", line 196, in clean_input return text.translate(config.clean_input_translation_map) TypeError: expected a character buffer object
Steps to reproduce
Visit User Preferences (Settings -> Settings), optionally change something, save, bang!
Needs more details! Strange: could not reproduce on http://linuxwiki.de/. Now I can't reproduce on http://moinmo.in any more.
If you see this error happening in your wiki, help finding a way to reproduce the problem.
Component selection
- userprefs/prefs, wikiutil.clean_input can only process unicode, not str
Details
MoinMoin Version |
1.7 repo code, 1.8.7, 1.9 repo code |
OS and Version |
Debian |
Python Version |
|
Server Setup |
apache2 and mod_wsgi (does NOT happen with wikiserver.py!) |
Server Details |
mod_wsgi/2.5 Python/2.5.2 |
Language you are using the wiki in (set in the browser/UserPreferences) |
|
Workaround
Put this into your farmconfig or wikiconfig:
# put this at the very end of the config, outside Config class, leftmost indenting level: from MoinMoin import wikiutil orig_clean_input = wikiutil.clean_input def clean_input(text): # 1.8.7 / 1.9.2pre wikiutil.clean_input can only process unicode, but sometimes gets str! return orig_clean_input(unicode(text)) wikiutil.clean_input = clean_input
Complementing patch
Even though clean_input is protected against '' by length check, according to its documentation, the text should be unicode. Hence I suggest the following complementing patch. -- RenatoSilva 2010-02-18 20:36:10
1 --- MoinMoin/userprefs/prefs.py 2010-02-18 17:44:57 -0200
2 +++ MoinMoin/userprefs/prefs.py 2010-02-18 17:45:33 -0200
3 @@ -108,7 +108,7 @@
4
5 if not 'jid' in request.user.auth_attribs:
6 # try to get the jid
7 - new_jid = wikiutil.clean_input(form.get('jid', '')).strip()
8 + new_jid = wikiutil.clean_input(form.get('jid', u'')).strip()
9
10 jid_changed = request.user.jid != new_jid
11 previous_jid = request.user.jid
12 @@ -130,7 +130,7 @@
13
14 if not 'aliasname' in request.user.auth_attribs:
15 # aliasname
16 - request.user.aliasname = wikiutil.clean_input(form.get('aliasname', ''))
17 + request.user.aliasname = wikiutil.clean_input(form.get('aliasname', u''))
18
19 # editor size
20 request.user.edit_rows = util.web.getIntegerInput(request, 'edit_rows',
Discussion
We need more betatesters!
There are three calls to clean_input in MoinMoin.userprefs.prefs, they all use form.get. Bug in werkzeug discarded by #moin/mitsuhiko. -- RenatoSilva 2010-02-18 21:02:01
I just saw this bug on http://live.gnome.org. -- Oliver 2010-03-14
They run 1.8.7 and the fix was short after 1.8.7 release. -- ThomasWaldmann 2010-03-14 10:29:55
Plan
- Priority:
- Assigned to:
- Status: fixed by: