(StrangeNewBannedContent): Extract

strange banned content comment and display it, if possible.
This commit is contained in:
Alex Schroeder
2007-01-14 16:03:25 +00:00
parent 23fbc25fa4
commit fc70881667

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2006 Alex Schroeder <alex@emacswiki.org>
# Copyright (C) 2006, 2007 Alex Schroeder <alex@emacswiki.org>
#
# 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 .= '<p>$Id: strange-spam.pl,v 1.10 2006/08/15 09:26:11 as Exp $</p>';
$ModulesDescription .= '<p>$Id: strange-spam.pl,v 1.11 2007/01/14 16:03:25 as Exp $</p>';
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;