r60818 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60817‎ | r60818 | r60819 >
Date:01:08, 8 January 2010
Author:robla
Status:deferred
Tags:
Comment:
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 (modified) (history)
  • /branches/extensionless-files/includes/StreamFile.php (modified) (history)
  • /branches/extensionless-files/includes/filerepo/FSRepo.php (modified) (history)
  • /branches/extensionless-files/includes/specials/SpecialUpload.php (modified) (history)

Diff [purge]

Index: branches/extensionless-files/includes/StreamFile.php
@@ -90,13 +90,13 @@
9191 * have changed since.
9292 */
9393 if ( $safe ) {
94 - global $wgFileBlacklist, $wgCheckFileExtensions, $wgStrictFileExtensions,
 94+ global $wgFileBlacklist, $wgStrictFileExtensions,
9595 $wgFileExtensions, $wgVerifyMimeType, $wgMimeTypeBlacklist, $wgRequest;
9696 list( $partName, $extList ) = UploadBase::splitExtensions( $filename );
9797 if ( UploadBase::checkFileExtensionList( $extList, $wgFileBlacklist ) ) {
9898 return 'unknown/unknown';
9999 }
100 - if ( $wgCheckFileExtensions && $wgStrictFileExtensions
 100+ if ( $wgStrictFileExtensions
101101 && !UploadBase::checkFileExtensionList( $extList, $wgFileExtensions ) )
102102 {
103103 return 'unknown/unknown';
Index: branches/extensionless-files/includes/filerepo/FSRepo.php
@@ -310,9 +310,9 @@
311311 * @return FileRepoStatus
312312 */
313313 function prepTarget( $targetRel ) {
314 - global $wgCheckFileExtensions;
315 - global $wgCheckFileExtensions, $wgStrictFileExtensions;
316 - global $wgFileExtensions, $wgFileBlacklist;
 314+ global $wgStrictFileExtensions;
 315+ global $wgFileExtensions, $wgFileBlacklist;
 316+
317317 $status = $this->newGood();
318318 if ( !$this->validateFilename( $targetRel ) ) {
319319 throw new MWException( 'Validation error in $targetRel' );
@@ -333,8 +333,7 @@
334334 $status->fatal( 'filetype-badmime', $mime );
335335 return $status;
336336 }
337 - if ( $wgCheckFileExtensions
338 - && $wgStrictFileExtensions
 337+ if ( $wgStrictFileExtensions
339338 && !in_array( $ext, $wgFileExtensions ) )
340339 {
341340 $status->fatal( 'filetype-badmime', $mime );
Index: branches/extensionless-files/includes/DefaultSettings.php
@@ -2173,14 +2173,6 @@
21742174 );
21752175
21762176 /**
2177 - * This is a flag to determine whether or not to check file extensions of
2178 - * resulting uploaded files from uploading or moving a file. This acts as a
2179 - * proxy for checking MIME types, and ensures files placed in $wgUploadDirectory
2180 - * have approved file extensions.
2181 - */
2182 -$wgCheckFileExtensions = true;
2183 -
2184 -/**
21852177 * This is a flag to determine whether or not to enforce matching of page title
21862178 * with file extensions of uploaded files (e.g if true, disallow a JPEG called
21872179 * "File:Foo", but allow "File:Foo.jpg").
Index: branches/extensionless-files/includes/specials/SpecialUpload.php
@@ -827,27 +827,25 @@
828828 protected function getExtensionsMessage() {
829829 # Print a list of allowed file extensions, if so configured. We ignore
830830 # MIME type here, it's incomprehensible to most people and too long.
831 - global $wgLang, $wgCheckFileExtensions, $wgStrictFileExtensions,
 831+ global $wgLang, $wgStrictFileExtensions,
832832 $wgFileExtensions, $wgFileBlacklist;
833833
834834 $allowedExtensions = '';
835 - if( $wgCheckFileExtensions ) {
836 - if( $wgStrictFileExtensions ) {
837 - # Everything not permitted is banned
838 - $extensionsList =
839 - '<div id="mw-upload-permitted">' .
840 - wfMsgWikiHtml( 'upload-permitted', $wgLang->commaList( $wgFileExtensions ) ) .
841 - "</div>\n";
842 - } else {
843 - # We have to list both preferred and prohibited
844 - $extensionsList =
845 - '<div id="mw-upload-preferred">' .
846 - wfMsgWikiHtml( 'upload-preferred', $wgLang->commaList( $wgFileExtensions ) ) .
847 - "</div>\n" .
848 - '<div id="mw-upload-prohibited">' .
849 - wfMsgWikiHtml( 'upload-prohibited', $wgLang->commaList( $wgFileBlacklist ) ) .
850 - "</div>\n";
851 - }
 835+ if( $wgStrictFileExtensions ) {
 836+ # Everything not permitted is banned
 837+ $extensionsList =
 838+ '<div id="mw-upload-permitted">' .
 839+ wfMsgWikiHtml( 'upload-permitted', $wgLang->commaList( $wgFileExtensions ) ) .
 840+ "</div>\n";
 841+ } elseif( !empty( $wgFileExtensions ) ) {
 842+ # We have to list both preferred and prohibited
 843+ $extensionsList =
 844+ '<div id="mw-upload-preferred">' .
 845+ wfMsgWikiHtml( 'upload-preferred', $wgLang->commaList( $wgFileExtensions ) ) .
 846+ "</div>\n" .
 847+ '<div id="mw-upload-prohibited">' .
 848+ wfMsgWikiHtml( 'upload-prohibited', $wgLang->commaList( $wgFileBlacklist ) ) .
 849+ "</div>\n";
852850 } else {
853851 # We still block the blacklisted stuff, because it's just nasty
854852 $extensionsList =

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r60773Decouple page titles from MIME type, adding img_file_ext field to db (bug 4421robla07:15, 7 January 2010

Status & tagging log