Skip to content
Browse files

Merge branch 'lollysite'

  • Loading branch information...
2 parents 82a5537 + c4e7548 commit 2e6f63fd0286f1a96cc770ab3bfcfffee895eb42 @chilts chilts committed May 11, 2010
Showing with 25 additions and 3 deletions.
  1. +1 −1 Makefile
  2. +9 −0 issues/i_d1d6a506.cil
  3. +12 −1 lollysite.py
  4. +3 −1 theme/admin/page-form.html
View
2 Makefile
@@ -2,7 +2,7 @@ all:
echo "Please specify a target"
start-chilts:
- ~/google_appengine/dev_appserver.py --datastore_path=store/chilts.db --history_path=store/data.db.history ./
+ ~/google_appengine/dev_appserver.py --datastore_path=store/chilts.db --history_path=store/chilts.db.history ./
start-fact-finder:
~/google_appengine/dev_appserver.py --datastore_path=store/fact-finder.db --history_path=store/data.db.history ./
View
9 issues/i_d1d6a506.cil
@@ -0,0 +1,9 @@
+Summary: Make it so that SPAM gets caught (multiple links)
+Status: Finished
+CreatedBy: Andrew Chilton <andychilton@gmail.com>
+AssignedTo: Andrew Chilton <andychilton@gmail.com>
+Inserted: 2010-04-25T05:35:16
+Updated: 2010-04-25T06:09:25
+
+A lot of spam has multiple links. If we can reject those that have more than 5
+links in a message, that'll get rid of a lot of them.
View
13 lollysite.py
@@ -61,6 +61,11 @@
label_page = re.compile('^label:(.+)$', re.DOTALL | re.VERBOSE)
archive_page = re.compile('^archive:(\d\d\d\d(-\d\d(-\d\d)?)?)$', re.DOTALL | re.VERBOSE)
+# allows us to check if this comment is spammy
+links = re.compile('https?://')
+def spammy_links(comment):
+ return False if len(re.findall(links, comment)) < 5 else True
+
## ----------------------------------------------------------------------------
class LollySite(webbase.WebBase):
@@ -231,7 +236,7 @@ def post(self):
# firstly, check the 'faux' field and if something is in there, redirect
faux = self.request.get('faux')
if len(faux) > 0:
- logging.info('COMMENT: Spam detected, not saving')
+ logging.info('COMMENT: Spam comment detected (Faux field not empty)')
self.redirect('/')
return
@@ -242,6 +247,12 @@ def post(self):
website = self.request.get('website')
comment_text = re.sub('\r', '', self.request.get('comment'));
+ # if there are more than 4 links (https?://) in the comment, we consider it spam
+ if spammy_links(comment_text):
+ logging.info('COMMENT: Spam comment detected (Too many links)')
+ self.redirect('/')
+ return
+
# now create the comment
comment = Comment(
node = node,
View
4 theme/admin/page-form.html
@@ -41,7 +41,9 @@
<tr>
<th><label for="id_label_raw">Label:</label></th>
- <td><input type="text" id="id_label_raw" name="label_raw" value="{{ item.label_raw|escape }}" /></td>
+ <td>
+ <input type="text" id="id_label_raw" name="label_raw" value="{{ item.label_raw|escape }}" /><br /><span class="msg">(Space separated, no commas.)</span>
+ </td>
</tr>
<tr>

0 comments on commit 2e6f63f

Please sign in to comment.
Something went wrong with that request. Please try again.