changeset 2992:954c617d9f76

antispam: check edit comments also against BadContent, use builtin frozenset, if possible (port from 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 06 Jan 2008 16:46:47 +0100
parents 82ac2b1b1a05
children aae2eac0894c
files MoinMoin/security/antispam.py
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/security/antispam.py	Sun Jan 06 16:43:38 2008 +0100
+++ b/MoinMoin/security/antispam.py	Sun Jan 06 16:46:47 2008 +0100
@@ -9,8 +9,14 @@
 # give some log entries to stderr
 debug = 0
 
-import re, sys, time, datetime
-import sets
+import re, time, datetime
+
+# needed for py 2.3 compat:
+try:
+    frozenset
+except NameError:
+    from sets import ImmutableSet as frozenset
+
 import logging
 
 from MoinMoin.security import Permissions
@@ -182,10 +188,10 @@
                     page = Page(request, editor.page_name, rev=rev)
                     oldtext = page.get_raw_body()
 
-                newset = sets.ImmutableSet(newtext.splitlines(1))
-                oldset = sets.ImmutableSet(oldtext.splitlines(1))
-                difference = newset.difference(oldset)
-                addedtext = ''.join(difference)
+                newset = frozenset(newtext.splitlines(1))
+                oldset = frozenset(oldtext.splitlines(1))
+                difference = newset - oldset
+                addedtext = kw.get('comment', u'') + u''.join(difference)
 
                 for blacklist_re in request.cfg.cache.antispam_blacklist[1]:
                     match = blacklist_re.search(addedtext)