changeset 1917:9a25a7ae3514

clean_comment added to some inputs
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 27 Mar 2007 19:48:21 +0000
parents d41e6ef31c0e
children 5abc7d1528d5
files MoinMoin/userform.py MoinMoin/wikiutil.py
diffstat 2 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/userform.py	Tue Mar 27 19:57:03 2007 +0200
+++ b/MoinMoin/userform.py	Tue Mar 27 19:48:21 2007 +0000
@@ -63,7 +63,7 @@
                 return _("""This wiki is not enabled for mail processing.
 Contact the owner of the wiki, who can enable email.""")
             try:
-                email = form['email'][0].lower()
+                email = wikiutil.clean_comment(form['email'][0].lower())
             except KeyError:
                 return _("Please provide a valid email address!")
 
@@ -124,7 +124,7 @@
                     return "Can't encode password: %s" % str(err)
 
             # try to get the (required) email
-            email = form.get('email', [''])[0]
+            email = wikiutil.clean_comment(form.get('email', [''])[0])
             theuser.email = email.strip()
             if not theuser.email:
                 return _("Please provide your email address. If you lose your"
@@ -214,7 +214,7 @@
 
             if not 'email' in theuser.auth_attribs:
                 # try to get the email
-                email = form.get('email', [theuser.email])[0]
+                email = wikiutil.clean_comment(form.get('email', [theuser.email])[0])
                 theuser.email = email.strip()
 
             # Require email
@@ -234,7 +234,7 @@
 
             if not 'aliasname' in theuser.auth_attribs:
                 # aliasname
-                theuser.aliasname = form.get('aliasname', [''])[0]
+                theuser.aliasname = wikiutil.clean_comment(form.get('aliasname', [''])[0])
 
             # editor size
             theuser.edit_rows = util.web.getIntegerInput(self.request, 'edit_rows', theuser.edit_rows, 10, 60)
--- a/MoinMoin/wikiutil.py	Tue Mar 27 19:57:03 2007 +0200
+++ b/MoinMoin/wikiutil.py	Tue Mar 27 19:48:21 2007 +0000
@@ -243,7 +243,12 @@
 def clean_comment(comment):
     """ Clean comment - replace CR, LF, TAB by whitespace, delete control chars
         TODO: move this to config, create on first call then return cached.
+        TODO: rename to clean_whatever
     """
+    # alias name could be empty
+    if len(comment) == 0:
+        return ''
+    
     # we only have input fields with max 200 chars, but spammers send us more
     if len(comment) > 201:
         comment = u''