Check that the MIME type is allowed before checking that it matches the extension...
authorIlmari Karonen <vyznev@users.mediawiki.org>
Fri, 21 Jan 2011 23:35:58 +0000 (23:35 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Fri, 21 Jan 2011 23:35:58 +0000 (23:35 +0000)
RELEASE-NOTES
includes/upload/UploadBase.php

index 59f1547..08fb831 100644 (file)
@@ -101,6 +101,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 26781) {{PAGENAME}} and related parser functions escape their output better.
 * (bug 26716) Provide link to instructions for external editor related preferences
   and add a comment to the ini control file explaining what is going on.
+* Trying to upload a file with no extension or with a disallowed MIME type now gives
+  the right message instead of complaining about a MIME/extension mismatch
 
 === API changes in 1.18 ===
 * (bug 26339) Throw warning when truncating an overlarge API result
index 86da818..84f78b2 100644 (file)
@@ -305,15 +305,16 @@ abstract class UploadBase {
                global $wgVerifyMimeType;
                if ( $wgVerifyMimeType ) {
                        wfDebug ( "\n\nmime: <$mime> extension: <{$this->mFinalExtension}>\n\n");
-                       if ( !$this->verifyExtension( $mime, $this->mFinalExtension ) ) {
-                               return array( 'filetype-mime-mismatch' );
-                       }
-
                        global $wgMimeTypeBlacklist;
                        if ( $this->checkFileExtension( $mime, $wgMimeTypeBlacklist ) ) {
                                return array( 'filetype-badmime', $mime );
                        }
 
+                       # XXX: Missing extension will be caught by validateName() via getTitle()
+                       if ( $this->mFinalExtension != '' && !$this->verifyExtension( $mime, $this->mFinalExtension ) ) {
+                               return array( 'filetype-mime-mismatch' );
+                       }
+
                        # Check IE type
                        $fp = fopen( $this->mTempPath, 'rb' );
                        $chunk = fread( $fp, 256 );