(bug 16772) Special:Upload now correctly rejects files with spaces in the file extens...
authorAlex Z <mrzman@users.mediawiki.org>
Tue, 23 Dec 2008 23:00:51 +0000 (23:00 +0000)
committerAlex Z <mrzman@users.mediawiki.org>
Tue, 23 Dec 2008 23:00:51 +0000 (23:00 +0000)
RELEASE-NOTES
includes/specials/SpecialUpload.php

index bf6ea48..6a072ee 100644 (file)
@@ -451,6 +451,8 @@ The following extensions are migrated into MediaWiki 1.14:
   redirectedfrom, historywarning and difference messages now use Wiki text
   rather than raw HTML markup
 * (bug 13835) Fix rendering of {{filepath:Wiki.png|nowiki}}
+* (bug 16772) Special:Upload now correctly rejects files with spaces in the
+  file extension (e.g. Foo. jpg).
 
 === API changes in 1.14 ===
 
index 335dd84..b841c05 100644 (file)
@@ -399,15 +399,20 @@ class UploadForm {
                        $basename = $this->mSrcName;
                }
                $filtered = wfStripIllegalFilenameChars( $basename );
-
+               
+               $nt = Title::makeTitleSafe( NS_FILE, $filtered );
+               if( is_null( $nt ) ) {
+                       $resultDetails = array( 'filtered' => $filtered );
+                       return self::ILLEGAL_FILENAME;
+               }
                /**
                 * We'll want to blacklist against *any* 'extension', and use
                 * only the final one for the whitelist.
                 */
-               list( $partname, $ext ) = $this->splitExtensions( $filtered );
+               list( $partname, $ext ) = $this->splitExtensions( $nt->getDBkey() );
 
                if( count( $ext ) ) {
-                       $finalExt = trim( $ext[count( $ext ) - 1] );
+                       $finalExt = $ext[count( $ext ) - 1];
                } else {
                        $finalExt = '';
                }
@@ -423,11 +428,6 @@ class UploadForm {
                        return self::MIN_LENGHT_PARTNAME;
                }
 
-               $nt = Title::makeTitleSafe( NS_FILE, $filtered );
-               if( is_null( $nt ) ) {
-                       $resultDetails = array( 'filtered' => $filtered );
-                       return self::ILLEGAL_FILENAME;
-               }
                $this->mLocalFile = wfLocalFile( $nt );
                $this->mDestName = $this->mLocalFile->getName();