r80730 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80729‎ | r80730 | r80731 >
Date:23:35, 21 January 2011
Author:vyznev
Status:ok
Tags:
Comment:
Check that the MIME type is allowed before checking that it matches the extension, and skip the latter check entirely if there is no extension so that the right message (filetype-missing) will be given instead of filetype-mime-mismatch.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/upload/UploadBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/upload/UploadBase.php
@@ -305,15 +305,16 @@
306306 global $wgVerifyMimeType;
307307 if ( $wgVerifyMimeType ) {
308308 wfDebug ( "\n\nmime: <$mime> extension: <{$this->mFinalExtension}>\n\n");
309 - if ( !$this->verifyExtension( $mime, $this->mFinalExtension ) ) {
310 - return array( 'filetype-mime-mismatch' );
311 - }
312 -
313309 global $wgMimeTypeBlacklist;
314310 if ( $this->checkFileExtension( $mime, $wgMimeTypeBlacklist ) ) {
315311 return array( 'filetype-badmime', $mime );
316312 }
317313
 314+ # XXX: Missing extension will be caught by validateName() via getTitle()
 315+ if ( $this->mFinalExtension != '' && !$this->verifyExtension( $mime, $this->mFinalExtension ) ) {
 316+ return array( 'filetype-mime-mismatch' );
 317+ }
 318+
318319 # Check IE type
319320 $fp = fopen( $this->mTempPath, 'rb' );
320321 $chunk = fread( $fp, 256 );
Index: trunk/phase3/RELEASE-NOTES
@@ -101,6 +101,8 @@
102102 * (bug 26781) {{PAGENAME}} and related parser functions escape their output better.
103103 * (bug 26716) Provide link to instructions for external editor related preferences
104104 and add a comment to the ini control file explaining what is going on.
 105+* Trying to upload a file with no extension or with a disallowed MIME type now gives
 106+ the right message instead of complaining about a MIME/extension mismatch
105107
106108 === API changes in 1.18 ===
107109 * (bug 26339) Throw warning when truncating an overlarge API result

Status & tagging log