diff --git a/SpamBlacklist.i18n.php b/SpamBlacklist.i18n.php index 3dd1a487..6541435d 100644 --- a/SpamBlacklist.i18n.php +++ b/SpamBlacklist.i18n.php @@ -52,6 +52,8 @@ $messages['en'] = array( 'spam-blacklisted-email-text' => 'Your email address is currently blacklisted from sending emails to other users.', 'spam-blacklisted-email-signup' => 'The given email address is currently blacklisted from use.', + 'spam-blacklisted-category' => 'Pages containing blacklisted links', + 'spam-invalid-lines' => "The following spam blacklist {{PLURAL:$1|line is an|lines are}} invalid regular {{PLURAL:$1|expression|expressions}} and {{PLURAL:$1|needs|need}} to be corrected before saving the page:", 'spam-blacklist-desc' => 'Regex-based anti-spam tool allowing to blacklist URLs in pages and email addresses for registered users', 'log-name-spamblacklist' => 'Spam blacklist log', @@ -77,6 +79,7 @@ $messages['qqq'] = array( 'spam-blacklisted-email' => 'Title of errorpage when trying to send an email with a blacklisted e-mail address', 'spam-blacklisted-email-text' => 'Text of errorpage when trying to send an e-mail with a blacklisted e-mail address', 'spam-blacklisted-email-signup' => 'Error when trying to create an account with an invalid e-mail address', + 'spam-blacklisted-category' => 'The category to place pages containing blacklisted links into', 'spam-invalid-lines' => 'Used as an error message. This message is followed by a list of bad lines. diff --git a/SpamBlacklist.php b/SpamBlacklist.php index 45e5237c..7cf171f1 100644 --- a/SpamBlacklist.php +++ b/SpamBlacklist.php @@ -58,6 +58,9 @@ $wgHooks['APIEditBeforeSave'][] = 'SpamBlacklistHooks::filterAPIEditBeforeSave'; $wgHooks['EditFilter'][] = 'SpamBlacklistHooks::validate'; $wgHooks['PageContentSaveComplete'][] = 'SpamBlacklistHooks::pageSaveContent'; +// categorize pages containing blacklisted links +$wgHooks['ParserAfterParse'][] = 'SpamBlacklistHooks::parserAfterParse'; + // email filters $wgHooks['UserCanSendEmail'][] = 'SpamBlacklistHooks::userCanSendEmail'; $wgHooks['AbortNewAccount'][] = 'SpamBlacklistHooks::abortNewAccount'; diff --git a/SpamBlacklistHooks.php b/SpamBlacklistHooks.php index 54f833cb..4c4da8b8 100644 --- a/SpamBlacklistHooks.php +++ b/SpamBlacklistHooks.php @@ -219,4 +219,12 @@ class SpamBlacklistHooks { } return true; } + + static function parserAfterParse( $parser, $text, $stripState ) { + $links = $parser->getOutput()->getExternalLinks(); + if ( $links && BaseBlacklist::getInstance( 'spam' )->filter( array_keys( $links ), null, true ) ) { + $parser->addTrackingCategory( 'spam-blacklisted-category' ); + } + return true; + } } diff --git a/SpamBlacklist_body.php b/SpamBlacklist_body.php index 15fbc72f..9adeee23 100644 --- a/SpamBlacklist_body.php +++ b/SpamBlacklist_body.php @@ -92,11 +92,11 @@ class SpamBlacklist extends BaseBlacklist { wfRestoreWarnings(); if( $check ) { wfDebugLog( 'SpamBlacklist', "Match!\n" ); - global $wgRequest; - $ip = $wgRequest->getIP(); - $imploded = implode( ' ', $matches[0] ); - wfDebugLog( 'SpamBlacklistHit', "$ip caught submitting spam: $imploded\n" ); if( !$preventLog ) { + global $wgRequest; + $ip = $wgRequest->getIP(); + $imploded = implode( ' ', $matches[0] ); + wfDebugLog( 'SpamBlacklistHit', "$ip caught submitting spam: $imploded\n" ); $this->logFilterHit( $title, $imploded ); // Log it } if( $retVal === false ){