From 2249c00041c82554d9a68b3fcc0b3ba5d62ff7c5 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Mon, 18 Jun 2007 06:35:20 +0000 Subject: [PATCH] Fixed regression in file type detection -- use the real file extension not the temporary file extension --- includes/SpecialUpload.php | 2 +- includes/filerepo/File.php | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index 38e670e65a..a22334123e 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -108,7 +108,6 @@ class UploadForm { $this->mFileSize = $request->getFileSize( 'wpUploadFile' ); $this->mSrcName = $request->getFileName( 'wpUploadFile' ); $this->mCurlError = $request->getUploadError( 'wpUploadFile' ); - $this->mFileProps = File::getPropsFromPath( $this->mTempPath ); $this->mSessionKey = false; $this->mStashed = false; $this->mRemoveTempFile = false; // PHP will handle this @@ -360,6 +359,7 @@ class UploadForm { * probably not accept it. */ if( !$this->mStashed ) { + $this->mFileProps = File::getPropsFromPath( $this->mTempPath, $finalExt ); $this->checkMacBinary(); $veri = $this->verify( $this->mTempPath, $finalExt ); diff --git a/includes/filerepo/File.php b/includes/filerepo/File.php index 4325f791c2..42ea9e7fdd 100644 --- a/includes/filerepo/File.php +++ b/includes/filerepo/File.php @@ -1001,9 +1001,13 @@ class File { } /** - * Get an associative array containing information about a file in the local filesystem + * Get an associative array containing information about a file in the local filesystem\ + * + * @param string $path Absolute local filesystem path + * @param mixed $ext The file extension, or true to extract it from the filename. + * Set it to false to ignore the extension. */ - static function getPropsFromPath( $path ) { + static function getPropsFromPath( $path, $ext = true ) { wfProfileIn( __METHOD__ ); wfDebug( __METHOD__.": Getting file info for $path\n" ); $info = array( 'fileExists' => file_exists( $path ) ); @@ -1011,7 +1015,7 @@ class File { if ( $info['fileExists'] ) { $magic = MimeMagic::singleton(); - $info['mime'] = $magic->guessMimeType( $path, true ); + $info['mime'] = $magic->guessMimeType( $path, $ext ); list( $info['major_mime'], $info['minor_mime'] ) = self::splitMime( $info['mime'] ); $info['media_type'] = $magic->getMediaType( $path, $info['mime'] ); -- 2.20.1