MediaWiki r16159 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r16158‎ | r16159 (on ViewVC)‎ | r16160 >
Date:10:14, 22 August 2006
Author:magnusmanske
Status:old
Tags:
Comment:
$wgMaxUploadSize now limits URL upload
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/SpecialUpload.php
===================================================================
--- trunk/phase3/includes/SpecialUpload.php	(revision 16158)
+++ trunk/phase3/includes/SpecialUpload.php	(revision 16159)
@@ -108,12 +108,12 @@
 	 * @access private
 	 */
 	function initialize_web_file( &$request ) {
-		global $wgTmpDirectory;
+		global $wgTmpDirectory, $wgMaxUploadSize;
 		$url = $request->getText( 'wpUploadFile' );
 		$local_file = tempnam( $wgTmpDirectory, 'WEBUPLOAD' );
 
-		# Maybe check for filesize($url) first?
-		$error = !@copy( $url, $local_file );
+		if ( $wgMaxUploadSize < @filesize ( $url ) ) $error = true ;
+		else $error = !@copy( $url, $local_file );
 		
 		$this->mUploadTempName = $local_file;
 		$this->mUploadSize     = filesize( $local_file );
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 16158)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 16159)
@@ -339,6 +339,8 @@
 $wgCacheSharedUploads = true;
 /** Allow for upload to be copied from an URL. Requires Special:Upload?source=web */
 $wgAllowCopyUploads = false;
+/** Max size for uploads, in bytes */
+$wgMaxUploadSize = 1024*1024*100; # 100MB
 
 /**
  * Point the upload navigation link to an external URL
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 16158)
+++ trunk/phase3/RELEASE-NOTES	(revision 16159)
@@ -148,6 +148,7 @@
 * Pass page title as parameters to "linkshere" and "nolinkshere" and update
   default message text
 * Allows to upload from publicy accessible URL. Set $wgAllowCopyUploads = true ; in LocalSettings.php
+  Limited to $wgMaxUploadSize (default:100MB)
 
 == Languages updated ==
 
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox