Maximum image area
authorTim Starling <tstarling@users.mediawiki.org>
Wed, 19 Oct 2005 12:12:14 +0000 (12:12 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Wed, 19 Oct 2005 12:12:14 +0000 (12:12 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/Image.php

index ef5d7b0..fb7c2d6 100644 (file)
@@ -157,6 +157,8 @@ fully support the editing toolbar, but was found to be too confusing.
   (requires PHP 5, XMLReader extension)
 * (bug 2773) Print style sheet no longer overrides RTL text direction
 * (bug 2938) Update MediaWiki:Exporttext to be more general
+* Fixed possible infinite loop in formatComment
+* Added a limit to the size of image files which can be thumbnailed
 
 
 === Caveats ===
index 4ab0c3b..2abb778 100644 (file)
@@ -1126,6 +1126,12 @@ $wgSVGConverter = 'ImageMagick';
 $wgSVGConverterPath = '';
 /** Don't scale a SVG larger than this unless its native size is larger */
 $wgSVGMaxSize = 1024;
+/** 
+ * Don't thumbnail an image if it will use too much working memory 
+ * Default is 50 MB if decompressed to RGBA form, which corresponds to 
+ * 12.5 million pixels or 3500x3500
+ */
+$wgMaxImageArea = 1.25e7;
 
 /** Set $wgCommandLineMode if it's not set already, to avoid notices */
 if( !isset( $wgCommandLineMode ) ) {
index 2ec5490..ffd647c 100644 (file)
@@ -919,6 +919,7 @@ class Image
        function renderThumb( $width, $useScript = true ) {
                global $wgUseSquid, $wgInternalServer;
                global $wgThumbnailScriptPath, $wgSharedThumbnailScriptPath;
+               global $wgSVGMaxSize, $wgMaxImageArea;
 
                $fname = 'Image::renderThumb';
                wfProfileIn( $fname );
@@ -940,7 +941,14 @@ class Image
                        return null;
                }
 
-               global $wgSVGMaxSize;
+               # Don't thumbnail an image so big that it will fill hard drives and send servers into swap
+               # JPEG has the handy property of allowing thumbnailing without full decompression, so we make
+               # an exception for it.
+               if ( $this->getMimeType() !== "image/jpeg" && $this->width * $this->height > $wgMaxImageArea ) {
+                       wfProfileOut( $fname );
+                       return null;
+               }
+
                $maxsize = $this->mustRender()
                        ? max( $this->width, $wgSVGMaxSize )
                        : $this->width - 1;