From 1ebaec186a4faefcecc1dfe36804afad0e913a51 Mon Sep 17 00:00:00 2001 From: Alex Z Date: Tue, 23 Dec 2008 23:00:51 +0000 Subject: [PATCH] (bug 16772) Special:Upload now correctly rejects files with spaces in the file extension (e.g. Foo. jpg) by normalizing the title before checking the extension. --- RELEASE-NOTES | 2 ++ includes/specials/SpecialUpload.php | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index bf6ea48209..6a072ee0a4 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 335dd8448c..b841c0572b 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -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(); -- 2.20.1