Skip to content

Commit

Permalink
Merge branch 'lollysite'
Browse files Browse the repository at this point in the history
  • Loading branch information
chilts committed May 11, 2010
2 parents 82a5537 + c4e7548 commit 2e6f63f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -2,7 +2,7 @@ all:
echo "Please specify a target" echo "Please specify a target"


start-chilts: 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: start-fact-finder:
~/google_appengine/dev_appserver.py --datastore_path=store/fact-finder.db --history_path=store/data.db.history ./ ~/google_appengine/dev_appserver.py --datastore_path=store/fact-finder.db --history_path=store/data.db.history ./
Expand Down
9 changes: 9 additions & 0 deletions 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.
13 changes: 12 additions & 1 deletion lollysite.py
Expand Up @@ -61,6 +61,11 @@
label_page = re.compile('^label:(.+)$', re.DOTALL | re.VERBOSE) 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) 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): class LollySite(webbase.WebBase):
Expand Down Expand Up @@ -231,7 +236,7 @@ def post(self):
# firstly, check the 'faux' field and if something is in there, redirect # firstly, check the 'faux' field and if something is in there, redirect
faux = self.request.get('faux') faux = self.request.get('faux')
if len(faux) > 0: if len(faux) > 0:
logging.info('COMMENT: Spam detected, not saving') logging.info('COMMENT: Spam comment detected (Faux field not empty)')
self.redirect('/') self.redirect('/')
return return


Expand All @@ -242,6 +247,12 @@ def post(self):
website = self.request.get('website') website = self.request.get('website')
comment_text = re.sub('\r', '', self.request.get('comment')); 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 # now create the comment
comment = Comment( comment = Comment(
node = node, node = node,
Expand Down
4 changes: 3 additions & 1 deletion theme/admin/page-form.html
Expand Up @@ -41,7 +41,9 @@ <h2>New {{type}}</h2>


<tr> <tr>
<th><label for="id_label_raw">Label:</label></th> <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>


<tr> <tr>
Expand Down

0 comments on commit 2e6f63f

Please sign in to comment.