changeset 1919:5abc7d1528d5

merged main
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 27 Mar 2007 21:50:05 +0200
parents bb2e053067fb (current diff) 9a25a7ae3514 (diff)
children b06ef2a53efa
files MoinMoin/PageEditor.py MoinMoin/userform.py MoinMoin/wikiutil.py
diffstat 4 files changed, 23 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageEditor.py	Tue Mar 27 21:07:33 2007 +0200
+++ b/MoinMoin/PageEditor.py	Tue Mar 27 21:50:05 2007 +0200
@@ -473,7 +473,7 @@
         """
         User clicked on Cancel button. If edit locking is active,
         delete the current lock file.
-        
+
         @param newtext: the edited text (which has been cancelled)
         @param rev: not used!?
         """
@@ -489,7 +489,7 @@
     def copyPage(self, newpagename, comment=None):
         """
         Copy the current version of the page (keeping the backups, logs and attachments).
-        
+
         @param comment: Comment given by user
         @rtype: unicode
         @return: success flag, error message
@@ -502,7 +502,7 @@
 
         if not self.request.user.may.write(newpagename):
             return False, _('You are not allowed to copy this page!')
-    
+
         newpage = PageEditor(request, newpagename)
 
         pageexists_error = _("""'''A page with the name {{{'%s'}}} already exists.'''
@@ -525,8 +525,9 @@
             self.error = None
             if not comment:
                 comment = u"## page was copied from %s" % self.page_name
-            if request.user.may.write(newpagename):
-                # If current user has write access
+            if request.user.may.write(self.page_name):
+                # ToDo: check difference to request.user.may.write(newpagename)
+                # If current user has write access to the old page
                 # Save page text with a comment about the old name
                 savetext = u"## page was copied from %s\n%s" % (self.page_name, savetext)
                 newpage.saveText(savetext, 0, comment=comment, index=0, extra=self.page_name, action='SAVE')
@@ -555,7 +556,7 @@
         """
         Rename the current version of the page (making a backup before deletion
         and keeping the backups, logs and attachments).
-        
+
         @param comment: Comment given by user
         @rtype: unicode
         @return: success flag, error message
@@ -633,7 +634,7 @@
         """
         Delete the current version of the page (making a backup before deletion
         and keeping the backups, logs and attachments).
-        
+
         @param comment: Comment given by user
         @rtype: unicode
         @return: success flag, error message
@@ -835,7 +836,7 @@
         You should normalize any text you enter into a page, for
         example, when getting new text from the editor, or when setting
         new text manually.
-                
+
         @param text: text to normalize (unicode)
         @keyword stripspaces: if 1, strip spaces from text
         @rtype: unicode
@@ -928,7 +929,7 @@
 
     def _write_file(self, text, action='SAVE', comment=u'', extra=u'', deleted=False):
         """ Write the text to the page file (and make a backup of old page).
-        
+
         @param text: text to save for this page
         @param deleted: if True, then don't write page content (used by deletePage)
         @rtype: int
@@ -1257,7 +1258,7 @@
     def release(self, force=0):
         """ 
         Release lock, if we own it.
-        
+
         @param force: if 1, unconditionally release the lock.
         """
         if self.locktype:
--- a/MoinMoin/search/Xapian.py	Tue Mar 27 21:07:33 2007 +0200
+++ b/MoinMoin/search/Xapian.py	Tue Mar 27 21:50:05 2007 +0200
@@ -11,6 +11,7 @@
 import os, re
 
 import xapian
+from xapian import Query
 
 from MoinMoin.support.xapwrap import document as xapdoc
 from MoinMoin.support.xapwrap import index as xapidx
@@ -27,7 +28,7 @@
     Stemmer = None
 
 
-class UnicodeQuery(xapian.Query):
+class UnicodeQuery(Query):
     """ Xapian query object which automatically encodes unicode strings """
     def __init__(self, *args, **kwargs):
         """
@@ -43,7 +44,7 @@
                 term = [t.encode(self.encoding) for t in term]
             nargs.append(term)
 
-        xapian.Query.__init__(self, *nargs, **kwargs)
+        Query.__init__(self, *nargs, **kwargs)
 
 
 ##############################################################################
--- a/MoinMoin/userform.py	Tue Mar 27 21:07:33 2007 +0200
+++ b/MoinMoin/userform.py	Tue Mar 27 21:50:05 2007 +0200
@@ -64,7 +64,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!")
 
@@ -125,7 +125,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"
@@ -215,7 +215,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
@@ -235,7 +235,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 21:07:33 2007 +0200
+++ b/MoinMoin/wikiutil.py	Tue Mar 27 21:50:05 2007 +0200
@@ -244,7 +244,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''