Make sure that thumbnail size is not overreported

Bug: 64661
Change-Id: Iece32c7875dc2e66f0f221649e7dc9c860451c07
This commit is contained in:
Max Semenik 2014-06-12 15:18:44 -07:00
parent 8af8f1844c
commit 195615137e

View file

@ -106,8 +106,11 @@ class ApiQueryPageImages extends ApiQueryBase {
if ( $thumb && $thumb->getUrl() ) {
$vals['thumbnail'] = array(
'source' => wfExpandUrl( $thumb->getUrl(), PROTO_CURRENT ),
'width' => $thumb->getWidth(),
'height' => $thumb->getHeight()
// You can request a thumb 1000x larger than the original which will return a Thumb
// object that will lie about its size but have the original as an image.
// Therefore, sanitize image size.
'width' => min( $thumb->getWidth(), $file->getWidth() ),
'height' => min( $thumb->getHeight(), $file->getHeight() ),
);
}
}