r43624 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43623‎ | r43624 | r43625 >
Date:18:58, 17 November 2008
Author:brion
Status:ok
Tags:
Comment:
* Improved input validation on Special:Import form
Applying Tim's fixes
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/specials/SpecialImport.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialImport.php
@@ -43,26 +43,30 @@
4444 if( $wgRequest->wasPosted() && $wgRequest->getVal( 'action' ) == 'submit') {
4545 $isUpload = false;
4646 $namespace = $wgRequest->getIntOrNull( 'namespace' );
 47+ $sourceName = $wgRequest->getVal( "source" );
4748
48 - switch( $wgRequest->getVal( "source" ) ) {
49 - case "upload":
 49+ if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'editToken' ) ) ) {
 50+ $source = new WikiErrorMsg( 'import-token-mismatch' );
 51+ } elseif ( $sourceName == 'upload' ) {
5052 $isUpload = true;
5153 if( $wgUser->isAllowed( 'importupload' ) ) {
5254 $source = ImportStreamSource::newFromUpload( "xmlimport" );
5355 } else {
5456 return $wgOut->permissionRequired( 'importupload' );
5557 }
56 - break;
57 - case "interwiki":
 58+ } elseif ( $sourceName == "interwiki" ) {
5859 $interwiki = $wgRequest->getVal( 'interwiki' );
59 - $history = $wgRequest->getCheck( 'interwikiHistory' );
60 - $frompage = $wgRequest->getText( "frompage" );
61 - $source = ImportStreamSource::newFromInterwiki(
62 - $interwiki,
63 - $frompage,
64 - $history );
65 - break;
66 - default:
 60+ if ( !in_array( $interwiki, $wgImportSources ) ) {
 61+ $source = new WikiErrorMsg( "import-invalid-interwiki" );
 62+ } else {
 63+ $history = $wgRequest->getCheck( 'interwikiHistory' );
 64+ $frompage = $wgRequest->getText( "frompage" );
 65+ $source = ImportStreamSource::newFromInterwiki(
 66+ $interwiki,
 67+ $frompage,
 68+ $history );
 69+ }
 70+ } else {
6771 $source = new WikiErrorMsg( "importunknownsource" );
6872 }
6973
@@ -106,6 +110,7 @@
107111 Xml::hidden( 'action', 'submit' ) .
108112 Xml::hidden( 'source', 'upload' ) .
109113 Xml::input( 'xmlimport', 50, '', array( 'type' => 'file' ) ) . ' ' .
 114+ Xml::hidden( 'editToken', $wgUser->editToken() ) .
110115 Xml::submitButton( wfMsg( 'uploadbtn' ) ) .
111116 Xml::closeElement( 'form' ) .
112117 Xml::closeElement( 'fieldset' )
@@ -124,6 +129,7 @@
125130 wfMsgExt( 'import-interwiki-text', array( 'parse' ) ) .
126131 Xml::hidden( 'action', 'submit' ) .
127132 Xml::hidden( 'source', 'interwiki' ) .
 133+ Xml::hidden( 'editToken', $wgUser->editToken() ) .
128134 Xml::openElement( 'table', array( 'id' => 'mw-import-table' ) ) .
129135 "<tr>
130136 <td>" .
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2803,6 +2803,8 @@
28042804 'import-nonewrevisions' => 'All revisions were previously imported.',
28052805 'xml-error-string' => '$1 at line $2, col $3 (byte $4): $5',
28062806 'import-upload' => 'Upload XML data',
 2807+'import-token-mismatch' => 'Loss of session data. Please try again.',
 2808+'import-invalid-interwiki' => 'Cannot import from the specified wiki.',
28072809
28082810 # Import log
28092811 'importlogpage' => 'Import log',
Index: trunk/phase3/RELEASE-NOTES
@@ -348,6 +348,7 @@
349349 formatting and path exposure.
350350 * Less verbose errors from profileinfo.php when not configured
351351 * Blacklist redirects via Special:Filepath, hard to use.
 352+* Improved input validation on Special:Import form
352353
353354
354355 === API changes in 1.14 ===

Follow-up revisions

RevisionCommit summaryAuthorDate
r43626Update messages.inc per r43624siebrand19:01, 17 November 2008
r43669Backported r43621, r43622, r43623, r43624, r43625, r43627, r43660, r43661. Ne...tstarling11:36, 18 November 2008

Status & tagging log