changeset 332:0a40d8a4057e

fixed logfile breaking when DeletePage/RenamePage comment contains CRLF chars imported from: moin--main--1.5--patch-336
author Thomas Waldmann <tw@waldmann-edv.de>
date Sun, 18 Dec 2005 20:14:48 +0000
parents 3fd688a3a370
children 5bfac46824a6
files MoinMoin/action/DeletePage.py MoinMoin/action/RenamePage.py MoinMoin/wikiaction.py MoinMoin/wikiutil.py docs/CHANGES
diffstat 5 files changed, 28 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/DeletePage.py	Sun Dec 18 19:45:58 2005 +0000
+++ b/MoinMoin/action/DeletePage.py	Sun Dec 18 20:14:48 2005 +0000
@@ -41,9 +41,11 @@
                 msg = _('Please use the interactive user interface to delete pages!'))
 
         # Delete the page
-        msg = page.deletePage(request.form.get('comment', [u''])[0])
+        comment = request.form.get('comment', [u''])[0]
+        comment = wikiutil.clean_comment(comment)
+        msg = page.deletePage(comment)
 
-        return page.send_page(request, msg = msg)
+        return page.send_page(request, msg=msg)
 
     # send deletion form
     ticket = wikiutil.createTicket()
--- a/MoinMoin/action/RenamePage.py	Sun Dec 18 19:45:58 2005 +0000
+++ b/MoinMoin/action/RenamePage.py	Sun Dec 18 20:14:48 2005 +0000
@@ -87,6 +87,7 @@
 
         # Get new name from form and normalize.
         comment = form.get('comment', [u''])[0]
+        comment = wikiutil.clean_comment(comment)
         newpagename = form.get('newpagename')[0]
         newpagename = self.request.normalizePagename(newpagename)
 
--- a/MoinMoin/wikiaction.py	Sun Dec 18 19:45:58 2005 +0000
+++ b/MoinMoin/wikiaction.py	Sun Dec 18 20:14:48 2005 +0000
@@ -577,19 +577,7 @@
     # one place before we manipulate the text.
     savetext = pg.normalizeText(savetext, stripspaces=rstrip)
 
-
-    # Clean comment - replace CR, LF, TAB by whitespace, delete control chars
-    # TODO: move this to config, create on first call then return cached.
-    remap_chars = {
-        ord(u'\t'): u' ',
-        ord(u'\r'): u' ',
-        ord(u'\n'): u' ',
-    }
-    control_chars = u'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e\x0f' \
-                    '\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'
-    for c in control_chars:
-        remap_chars[c] = None
-    comment = comment.translate(remap_chars)
+    comment = wikiutil.clean_comment(comment)
 
     # Edit was canceled
     if request.form.has_key('button_cancel'):
--- a/MoinMoin/wikiutil.py	Sun Dec 18 19:45:58 2005 +0000
+++ b/MoinMoin/wikiutil.py	Sun Dec 18 20:14:48 2005 +0000
@@ -240,6 +240,22 @@
         s = s.replace('"', "&quot;")
     return s
 
+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.
+    """
+    remap_chars = {
+        ord(u'\t'): u' ',
+        ord(u'\r'): u' ',
+        ord(u'\n'): u' ',
+    }
+    control_chars = u'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e\x0f' \
+                    '\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'
+    for c in control_chars:
+        remap_chars[c] = None
+    comment = comment.translate(remap_chars)
+    return comment
+
 def make_breakable(text, maxlen):
     """ make a text breakable by inserting spaces into nonbreakable parts
     """
--- a/docs/CHANGES	Sun Dec 18 19:45:58 2005 +0000
+++ b/docs/CHANGES	Sun Dec 18 20:14:48 2005 +0000
@@ -30,6 +30,12 @@
     * Many (50+) tests are currently failing because they are too restrictive
       and do not match the (output of the) code they should test.
 
+  Fixes:
+    * fixed broken logs when a DeletePage (maybe also RenamePage) comment
+      contained CR/LF characters (could happen when using copy&paste)
+    * fixed GUI editor MoinEditorBackup page containing HTML instead of wiki
+      markup
+
 
 Version 1.5.0beta6:
   Authentication: