Made two new global variables for checking file extensions. The list of
authorEvan Prodromou <evanprodromou@users.mediawiki.org>
Tue, 9 Dec 2003 18:20:32 +0000 (18:20 +0000)
committerEvan Prodromou <evanprodromou@users.mediawiki.org>
Tue, 9 Dec 2003 18:20:32 +0000 (18:20 +0000)
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
includes/SpecialUpload.php

index ed08e9b..e5ae725 100644 (file)
@@ -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?
index 16ab982..03041de 100644 (file)
@@ -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" ) );