From: Kunal Mehta Date: Thu, 17 Oct 2013 06:48:48 +0000 (-0700) Subject: Merge SimpleAntiSpam extension into core X-Git-Tag: 1.31.0-rc.0~18405 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22sites_tous%22%29%20.%20%22?a=commitdiff_plain;h=0988d1200dd5d67719baf076cdbe3e363801ac23;p=lhc%2Fweb%2Fwiklou.git Merge SimpleAntiSpam extension into core Adds an empty, hidden input field to the edit interface, and will reject any edit if that field is filled in. This will protect against the simplest form of spambots. Localized messages will be imported separately. Bug: 52063 Change-Id: I185b6a1e232299f496244a23f4bf0dc6ea22b6c9 --- diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index d6a75bac4c..091a04aabf 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -256,6 +256,9 @@ production. * Added a hook, SpecialWatchlistGetNonRevisionTypes, to allow extensions with custom recentchanges entries to hook into the Watchlist without clobbering each other. +* A hidden, empty input field was added to the edit form, and any edit that fills + it in will be rejected. This prevents against the simplest form of spambots. + Previously in the "SimpleAntiSpam" extension by Ryan Schmidt. === Bug fixes in 1.22 === * Disable Special:PasswordReset when $wgEnableEmail is false. Previously one diff --git a/includes/EditPage.php b/includes/EditPage.php index d7b2b5e235..530e267453 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1381,6 +1381,24 @@ class EditPage { return $status; } + $spam = $wgRequest->getText( 'wpAntispam' ); + if ( $spam !== '' ) { + wfDebugLog( + 'SimpleAntiSpam', + $wgUser->getName() . + ' editing "' . + $this->mTitle->getPrefixedText() . + '" submitted bogus field "' . + $spam . + '"' + ); + $status->fatal( 'spamprotectionmatch', false ); + $status->value = self::AS_SPAM_ERROR; + wfProfileOut( __METHOD__ . '-checks' ); + wfProfileOut( __METHOD__ ); + return $status; + } + try { # Construct Content object $textbox_content = $this->toEditContent( $this->textbox1 ); @@ -2190,6 +2208,14 @@ class EditPage { call_user_func_array( $formCallback, array( &$wgOut ) ); } + // Add an empty field to trip up spambots + $wgOut->addHTML( + Xml::openElement( 'div', array( 'id' => 'antispam-container', 'style' => 'display: none;' ) ) + . Html::rawElement( 'label', array( 'for' => 'wpAntiSpam' ), wfMessage( 'simpleantispam-label' )->parse() ) + . Xml::element( 'input', array( 'type' => 'text', 'name' => 'wpAntispam', 'id' => 'wpAntispam', 'value' => '' ) ) + . Xml::closeElement( 'div' ) + ); + wfRunHooks( 'EditPage::showEditForm:fields', array( &$this, &$wgOut ) ); // Put these up at the top to ensure they aren't lost on early form submission diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 2cefeb8a05..0c1b56031e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -3851,6 +3851,8 @@ This is probably caused by a link to a blacklisted external site.', 'spam_reverting' => 'Reverting to last revision not containing links to $1', 'spam_blanking' => 'All revisions contained links to $1, blanking', 'spam_deleting' => 'All revisions contained links to $1, deleting', +'simpleantispam-label' => "Anti-spam check. +Do '''NOT''' fill this in!", # Info page 'pageinfo-header' => '-', # do not translate or duplicate this message to other languages diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index a94b6d5451..a4fc922bcd 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -2776,6 +2776,7 @@ $wgMessageStructure = array( 'spam_reverting', 'spam_blanking', 'spam_deleting', + 'simpleantispam-label', ), 'info' => array( 'pageinfo-header',