From c8f7249f9fc4d2bb1ef719aa006682b688cab3c2 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Tue, 4 Apr 2006 15:26:55 +0000 Subject: [PATCH] Fix bogus "filename too short" error when uploading files with a period in the base name, e.g. "Mr. Zee.png" --- RELEASE-NOTES | 2 ++ includes/SpecialUpload.php | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b8f1376caa..4d32e28b65 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index 8bdfd8e296..31c4f3c257 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -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; -- 2.20.1