From fc7088166791c4447e00deef792f6ff2f50ca192 Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Sun, 14 Jan 2007 16:03:25 +0000 Subject: [PATCH] (StrangeNewBannedContent): Extract strange banned content comment and display it, if possible. --- modules/strange-spam.pl | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/strange-spam.pl b/modules/strange-spam.pl index 5c206a6b..ce0ca138 100644 --- a/modules/strange-spam.pl +++ b/modules/strange-spam.pl @@ -1,4 +1,4 @@ -# Copyright (C) 2006 Alex Schroeder +# Copyright (C) 2006, 2007 Alex Schroeder # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ # 59 Temple Place, Suite 330 # Boston, MA 02111-1307 USA -$ModulesDescription .= '

$Id: strange-spam.pl,v 1.10 2006/08/15 09:26:11 as Exp $

'; +$ModulesDescription .= '

$Id: strange-spam.pl,v 1.11 2007/01/14 16:03:25 as Exp $

'; use vars qw($StrangeBannedContent); @@ -40,16 +40,18 @@ sub StrangeNewBannedContent { my $str = shift; my $rule = StrangeOldBannedContent($str, @_); return $rule if $rule; - foreach (grep /./, map { - s/#.*//; # trim comments - s/^\s+//; # trim leading whitespace - s/\s+$//; # trim trailing whitespace - $_; } split(/\n/, GetPageContent($StrangeBannedContent))) { - my $regexp = $_; - next unless $regexp; # skip empty strings + foreach (split(/\n/, GetPageContent($StrangeBannedContent))) { + next unless m/^\s*([^# \t]+)\s*(#\s*(\d\d\d\d-\d\d-\d\d\s*)?(.*))?/; + my ($regexp, $comment) = ($1, $4); if ($str =~ /($regexp)/i) { my $match = $1; - return Tss('Rule "%1" matched "%2" on this page.', QuoteHtml($regexp), QuoteHtml($match)); + return Tss('Rule "%1" matched "%2" on this page.', QuoteHtml($regexp), + QuoteHtml($match)) . ' ' + . ($comment + ? Ts('Reason: %s.', $comment) + : T('Reason unknown.')) . ' ' + . Ts('See %s for more information.', + GetPageLink($StrangeBannedContent)); } } return 0;