http://www.mediawiki.org/wiki/Special:Code/MediaWiki/60818

Revision: 60818
Author:   robla
Date:     2010-01-08 01:08:28 +0000 (Fri, 08 Jan 2010)

Log Message:
-----------
Followup to r60773.  Getting rid of $wgCheckFileExtensions as in its current
form, since all of the remaining checks are superfluous.

Modified Paths:
--------------
    branches/extensionless-files/includes/DefaultSettings.php
    branches/extensionless-files/includes/StreamFile.php
    branches/extensionless-files/includes/filerepo/FSRepo.php
    branches/extensionless-files/includes/specials/SpecialUpload.php

Modified: branches/extensionless-files/includes/DefaultSettings.php
===================================================================
--- branches/extensionless-files/includes/DefaultSettings.php   2010-01-08 
00:51:35 UTC (rev 60817)
+++ branches/extensionless-files/includes/DefaultSettings.php   2010-01-08 
01:08:28 UTC (rev 60818)
@@ -2173,14 +2173,6 @@
 );
 
 /** 
- * This is a flag to determine whether or not to check file extensions of 
- * resulting uploaded files from uploading or moving a file.  This acts as a 
- * proxy for checking MIME types, and ensures files placed in 
$wgUploadDirectory
- * have approved file extensions.
- */
-$wgCheckFileExtensions = true;
-
-/** 
  * This is a flag to determine whether or not to enforce matching of page title
  * with file extensions of uploaded files (e.g if true, disallow a JPEG called
  * "File:Foo", but allow "File:Foo.jpg").

Modified: branches/extensionless-files/includes/StreamFile.php
===================================================================
--- branches/extensionless-files/includes/StreamFile.php        2010-01-08 
00:51:35 UTC (rev 60817)
+++ branches/extensionless-files/includes/StreamFile.php        2010-01-08 
01:08:28 UTC (rev 60818)
@@ -90,13 +90,13 @@
         * have changed since.
         */
        if ( $safe ) {
-               global $wgFileBlacklist, $wgCheckFileExtensions, 
$wgStrictFileExtensions, 
+               global $wgFileBlacklist, $wgStrictFileExtensions, 
                        $wgFileExtensions, $wgVerifyMimeType, 
$wgMimeTypeBlacklist, $wgRequest;
                list( $partName, $extList ) = UploadBase::splitExtensions( 
$filename );
                if ( UploadBase::checkFileExtensionList( $extList, 
$wgFileBlacklist ) ) {
                        return 'unknown/unknown';
                }
-               if ( $wgCheckFileExtensions && $wgStrictFileExtensions 
+               if ( $wgStrictFileExtensions 
                        && !UploadBase::checkFileExtensionList( $extList, 
$wgFileExtensions ) )
                {
                        return 'unknown/unknown';

Modified: branches/extensionless-files/includes/filerepo/FSRepo.php
===================================================================
--- branches/extensionless-files/includes/filerepo/FSRepo.php   2010-01-08 
00:51:35 UTC (rev 60817)
+++ branches/extensionless-files/includes/filerepo/FSRepo.php   2010-01-08 
01:08:28 UTC (rev 60818)
@@ -310,9 +310,9 @@
         * @return FileRepoStatus
         */
        function prepTarget( $targetRel ) {
-               global $wgCheckFileExtensions;
-                       global $wgCheckFileExtensions, $wgStrictFileExtensions;
-                       global $wgFileExtensions, $wgFileBlacklist;
+               global $wgStrictFileExtensions;
+               global $wgFileExtensions, $wgFileBlacklist;
+
                $status = $this->newGood();
                if ( !$this->validateFilename( $targetRel ) ) {
                        throw new MWException( 'Validation error in $targetRel' 
);
@@ -333,8 +333,7 @@
                        $status->fatal( 'filetype-badmime', $mime );
                        return $status;
                }
-               if ( $wgCheckFileExtensions
-                       && $wgStrictFileExtensions
+               if ( $wgStrictFileExtensions
                        && !in_array( $ext, $wgFileExtensions ) ) 
                {
                        $status->fatal( 'filetype-badmime', $mime );

Modified: branches/extensionless-files/includes/specials/SpecialUpload.php
===================================================================
--- branches/extensionless-files/includes/specials/SpecialUpload.php    
2010-01-08 00:51:35 UTC (rev 60817)
+++ branches/extensionless-files/includes/specials/SpecialUpload.php    
2010-01-08 01:08:28 UTC (rev 60818)
@@ -827,27 +827,25 @@
        protected function getExtensionsMessage() {
                # Print a list of allowed file extensions, if so configured.  
We ignore
                # MIME type here, it's incomprehensible to most people and too 
long.
-               global $wgLang, $wgCheckFileExtensions, $wgStrictFileExtensions,
+               global $wgLang, $wgStrictFileExtensions,
                $wgFileExtensions, $wgFileBlacklist;
 
                $allowedExtensions = '';
-               if( $wgCheckFileExtensions ) {
-                       if( $wgStrictFileExtensions ) {
-                               # Everything not permitted is banned
-                               $extensionsList =
-                                       '<div id="mw-upload-permitted">' .
-                                       wfMsgWikiHtml( 'upload-permitted', 
$wgLang->commaList( $wgFileExtensions ) ) .
-                                       "</div>\n";
-                       } else {
-                               # We have to list both preferred and prohibited
-                               $extensionsList =
-                                       '<div id="mw-upload-preferred">' .
-                                       wfMsgWikiHtml( 'upload-preferred', 
$wgLang->commaList( $wgFileExtensions ) ) .
-                                       "</div>\n" .
-                                       '<div id="mw-upload-prohibited">' .
-                                       wfMsgWikiHtml( 'upload-prohibited', 
$wgLang->commaList( $wgFileBlacklist ) ) .
-                                       "</div>\n";
-                       }
+               if( $wgStrictFileExtensions ) {
+                       # Everything not permitted is banned
+                       $extensionsList =
+                               '<div id="mw-upload-permitted">' .
+                               wfMsgWikiHtml( 'upload-permitted', 
$wgLang->commaList( $wgFileExtensions ) ) .
+                               "</div>\n";
+               } elseif( !empty( $wgFileExtensions ) ) {
+                       # We have to list both preferred and prohibited
+                       $extensionsList =
+                               '<div id="mw-upload-preferred">' .
+                               wfMsgWikiHtml( 'upload-preferred', 
$wgLang->commaList( $wgFileExtensions ) ) .
+                               "</div>\n" .
+                               '<div id="mw-upload-prohibited">' .
+                               wfMsgWikiHtml( 'upload-prohibited', 
$wgLang->commaList( $wgFileBlacklist ) ) .
+                               "</div>\n";
                } else {
                        # We still block the blacklisted stuff, because it's 
just nasty
                        $extensionsList =



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to