Fix bogus "filename too short" error when uploading files with a period in the base...
authorRob Church <robchurch@users.mediawiki.org>
Tue, 4 Apr 2006 15:26:55 +0000 (15:26 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Tue, 4 Apr 2006 15:26:55 +0000 (15:26 +0000)
RELEASE-NOTES
includes/SpecialUpload.php

index b8f1376..4d32e28 100644 (file)
@@ -777,6 +777,8 @@ fully support the editing toolbar, but was found to be too confusing.
 * (bug 5195) rebuildrecentchanges.php works again; Database::insertSelect now
   has a parameter for select options.
 * Fix updateSearchIndex.php for new schema
+* Fix bogus "filename too short" error when uploading files with a period in the base
+  name, e.g. "Mr. Zee.png"
 
 
 === Caveats ===
index 8bdfd8e..31c4f3c 100644 (file)
@@ -181,6 +181,7 @@ class UploadForm {
                 * only the final one for the whitelist.
                 */
                list( $partname, $ext ) = $this->splitExtensions( $basename );
+               
                if( count( $ext ) ) {
                        $finalExt = $ext[count( $ext ) - 1];
                } else {
@@ -188,6 +189,13 @@ class UploadForm {
                }
                $fullExt = implode( '.', $ext );
 
+               # If there was more than one "extension", reassemble the base
+               # filename to prevent bogus complaints about length
+               if( count( $ext ) > 1 ) {
+                       for( $i = 0; $i < count( $ext ) - 1; $i++ )
+                               $partname .= '.' . $ext[$i];
+               }
+
                if ( strlen( $partname ) < 3 ) {
                        $this->mainUploadForm( wfMsgHtml( 'minlength' ) );
                        return;