r23621 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23620‎ | r23621 | r23622 >
Date:22:22, 1 July 2007
Author:tstarling
Status:old
Tags:
Comment:
Display a distinctive message when the edit token suffix is mangled. On report of widespread bot breakage, due to adding "+".
Modified paths:
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -2312,7 +2312,6 @@
23132313 * @public
23142314 */
23152315 function matchEditToken( $val, $salt = '' ) {
2316 - global $wgMemc;
23172316 $sessionToken = $this->editToken( $salt );
23182317 if ( $val != $sessionToken ) {
23192318 wfDebug( "User::matchEditToken: broken session data\n" );
@@ -2321,6 +2320,14 @@
23222321 }
23232322
23242323 /**
 2324+ * Check whether the edit token is fine except for the suffix
 2325+ */
 2326+ function matchEditTokenNoSuffix( $val, $salt = '' ) {
 2327+ $sessionToken = $this->editToken( $salt );
 2328+ return substr( $sessionToken, 0, 32 ) == substr( $val, 0, 32 );
 2329+ }
 2330+
 2331+ /**
23252332 * Generate a new e-mail confirmation token and send a confirmation
23262333 * mail to the user's given address.
23272334 *
Index: trunk/phase3/includes/EditPage.php
@@ -20,6 +20,7 @@
2121 var $firsttime;
2222 var $lastDelete;
2323 var $mTokenOk = false;
 24+ var $mTokenOkExceptSuffix = false;
2425 var $mTriedSave = false;
2526 var $tooBig = false;
2627 var $kblength = false;
@@ -576,7 +577,9 @@
577578 */
578579 function tokenOk( &$request ) {
579580 global $wgUser;
580 - $this->mTokenOk = $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
 581+ $token = $request->getVal( 'wpEditToken' );
 582+ $this->mTokenOk = $wgUser->matchEditToken( $token );
 583+ $this->mTokenOkExceptSuffix = $wgUser->matchEditTokenNoSuffix( $token );
581584 return $this->mTokenOk;
582585 }
583586
@@ -1369,7 +1372,11 @@
13701373 wfProfileIn( $fname );
13711374
13721375 if ( $this->mTriedSave && !$this->mTokenOk ) {
1373 - $msg = 'session_fail_preview';
 1376+ if ( $this->mTokenOkExceptSuffix ) {
 1377+ $msg = 'token_suffix_mismatch';
 1378+ } else {
 1379+ $msg = 'session_fail_preview';
 1380+ }
13741381 } else {
13751382 $msg = 'previewnote';
13761383 }
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -995,6 +995,9 @@
996996 ''Because this wiki has raw HTML enabled, the preview is hidden as a precaution against JavaScript attacks.''
997997
998998 <strong>If this is a legitimate edit attempt, please try again. If it still doesn't work, try logging out and logging back in.</strong>",
 999+'token_suffix_mismatch' => '<strong>Your edit has been rejected because your client mangled the punctuation characters
 1000+in the edit token. The edit has been rejected to prevent corruption of the article text.
 1001+This sometimes happens when you are using a buggy web-based anonymous proxy service.</strong>',
9991002 'importing' => 'Importing $1',
10001003 'editing' => 'Editing $1',
10011004 'editinguser' => 'Editing user <b>$1</b>',

Follow-up revisions

RevisionCommit summaryAuthorDate
r23662Merged revisions 23581-23661 via svnmerge from...david03:01, 3 July 2007

Status & tagging log