diff options
author | Gergő Tisza <tgr.huwiki@gmail.com> | 2015-02-05 00:26:38 +0000 |
---|---|---|
committer | Gergő Tisza <tgr.huwiki@gmail.com> | 2015-02-05 00:26:38 +0000 |
commit | 5cea189b1b881d44413152349ec27425f10bdb3f (patch) | |
tree | a11f6062b9cbae7a10108e2bc6485130f0a67d31 /thumb.php | |
parent | 62e8e5dfce145ad972c5c277b6be1f4e6af42bb0 (diff) | |
download | mediawikicore-5cea189b1b881d44413152349ec27425f10bdb3f.tar.gz mediawikicore-5cea189b1b881d44413152349ec27425f10bdb3f.zip |
Make thumb.php respond with HTTP 400 (not 500) on invalid parameters
Bug: T88412
Change-Id: I21d34a3fb52992e51122ab7c07a38e946a55c680
Diffstat (limited to 'thumb.php')
-rw-r--r-- | thumb.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/thumb.php b/thumb.php index 7352dc4c5b82..ebcf79f7432c 100644 --- a/thumb.php +++ b/thumb.php @@ -321,6 +321,7 @@ function wfStreamThumb( array $params ) { // Check for thumbnail generation errors... $msg = wfMessage( 'thumbnail_error' ); + $errorCode = 500; if ( !$thumb ) { $errorMsg = $errorMsg ?: $msg->rawParams( 'File::transform() returned false' )->escaped(); } elseif ( $thumb->isError() ) { @@ -330,10 +331,11 @@ function wfStreamThumb( array $params ) { } elseif ( $thumb->fileIsSource() ) { $errorMsg = $msg-> rawParams( 'Image was not scaled, is the requested width bigger than the source?' )->escaped(); + $errorCode = 400; } if ( $errorMsg !== false ) { - wfThumbError( 500, $errorMsg ); + wfThumbError( $errorCode, $errorMsg ); } else { // Stream the file if there were no errors $thumb->streamFile( $headers ); @@ -605,7 +607,9 @@ function wfThumbError( $status, $msg ) { header( 'Cache-Control: no-cache' ); header( 'Content-Type: text/html; charset=utf-8' ); - if ( $status == 404 ) { + if ( $status == 400 ) { + header( 'HTTP/1.1 400 Bad request' ); + } elseif ( $status == 404 ) { header( 'HTTP/1.1 404 Not found' ); } elseif ( $status == 403 ) { header( 'HTTP/1.1 403 Forbidden' ); |