From 9dda120350bf7b267d92ca0d551c4c4998256e92 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 9 Dec 2003 18:20:32 +0000 Subject: [PATCH] Made two new global variables for checking file extensions. The list of extensions is now configurable, and you can turn on and off file extension checking. There isn't yet a "hard" check, though. --- includes/DefaultSettings.php | 10 ++++++++++ includes/SpecialUpload.php | 11 +++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index ed08e9b056..e5ae7254bb 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -152,6 +152,16 @@ $wgDisableAnonTalk = false; # Requires zlib support enabled in PHP. $wgUseGzip = false; +# This is the list of preferred extensions for uploading files. Uploading +# files with extensions not in this list will trigger a warning. + +$wgFileExtensions = array( "png", "jpg", "jpeg", "ogg" ); + +# This is a flag to determine whether or not to check file extensions on +# upload. + +$wgCheckFileExtensions = true; + $wgPasswordSalt = true; # For compatibility with old installations set to false # Which namespaces should support subpages? diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index 16ab982063..03041de63e 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -39,7 +39,8 @@ function processUpload() global $wpUploadSaveName, $wpUploadTempName, $wpUploadSize; global $wgSavedFile, $wgUploadOldVersion, $wpUploadOldVersion; global $wgUseCopyrightUpload , $wpUploadCopyStatus , $wpUploadSource ; - + global $wgCheckFileExtensions, $wgFileExtensions; + if ( $wgUseCopyrightUpload ) { $wpUploadAffirm = 1 ; @@ -86,10 +87,12 @@ function processUpload() ( 0 != strcmp( ucfirst( $basename ), $wpUploadSaveName ) ) ) { return uploadWarning( wfMsg( "badfilename", $wpUploadSaveName ) ); } - $extensions = array( "png", "jpg", "jpeg", "ogg" ); - if ( ( ! $wpIgnoreWarning ) && - ( ! in_array( strtolower( $ext ), $extensions ) ) ) { + + if ( $wgCheckFileExtensions ) { + if ( ( ! $wpIgnoreWarning ) && + ( ! in_array( strtolower( $ext ), $wgFileExtensions ) ) ) { return uploadWarning( wfMsg( "badfiletype", $ext ) ); + } } if ( ( ! $wpIgnoreWarning ) && ( $wpUploadSize > 150000 ) ) { return uploadWarning( WfMsg( "largefile" ) ); -- 2.20.1