changeset 330:2179834db5e1

fixed MoinMoinBugs/GuiEditorSavesHtmlAsBackup imported from: moin--main--1.5--patch-334
author Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
date Sun, 18 Dec 2005 18:05:00 +0000
parents b577fa7d1409
children 3fd688a3a370
files MoinMoin/wikiaction.py
diffstat 1 files changed, 19 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/wikiaction.py	Sun Dec 18 17:39:18 2005 +0000
+++ b/MoinMoin/wikiaction.py	Sun Dec 18 18:05:00 2005 +0000
@@ -563,11 +563,6 @@
         from MoinMoin.PageEditor import PageEditor
         pg = PageEditor(request, pagename)
 
-    # Edit was canceled
-    if request.form.has_key('button_cancel'):
-        pg.sendCancel(savetext or "", rev)
-        return
-
     # is invoked without savetext start editing
     if savetext is None:
         pg.sendEditor()
@@ -582,6 +577,25 @@
     # 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)
+
+    # Edit was canceled
+    if request.form.has_key('button_cancel'):
+        pg.sendCancel(savetext or "", rev)
+        return
+
     # Add category
 
     # TODO: this code does not work with extended links, and is doing
@@ -613,19 +627,6 @@
             savetext += ' '
         savetext += category + u'\n' # Should end with newline!
 
-    # 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)
-
     # Preview, spellcheck or spellcheck add new words
     if (request.form.has_key('button_preview') or
         request.form.has_key('button_spellcheck') or