Page MenuHomePhorge

No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None
diff --git a/includes/filerepo/ThumbnailEntryPoint.php b/includes/filerepo/ThumbnailEntryPoint.php
index e8367ada0d2..afaad7096b1 100644
--- a/includes/filerepo/ThumbnailEntryPoint.php
+++ b/includes/filerepo/ThumbnailEntryPoint.php
@@ -192,7 +192,7 @@ class ThumbnailEntryPoint extends MediaWikiEntryPoint {
// Check the source file storage path
if ( !$img->exists() ) {
- $redirected = $this->maybeDoRedirect(
+ $redirectedHasTarget = $this->maybeDoRedirect(
$img,
$params,
$isTemp,
@@ -200,7 +200,7 @@ class ThumbnailEntryPoint extends MediaWikiEntryPoint {
$archiveTimestamp
);
- if ( !$redirected ) {
+ if ( !$redirectedHasTarget ) {
// If it's not a redirect that has a target as a local file, give 404.
$this->thumbErrorText(
404,
@@ -610,7 +610,7 @@ EOT;
}
/**
- * @return bool true if redirected
+ * @return bool true if a redirect target was found, false otherwise.
*/
private function maybeDoRedirect(
File $img,
@@ -637,7 +637,17 @@ EOT;
)
);
if ( $targetFile->exists() ) {
- $newThumbName = $targetFile->thumbName( $params );
+ // Get the normalized thumbnail name from the parameters...
+ try {
+ $newThumbName = $targetFile->thumbName( $params );
+ } catch ( MediaTransformInvalidParametersException $e ) {
+ $this->thumbErrorText(
+ 400,
+ 'The specified thumbnail parameters are not valid: ' . $e->getMessage()
+ );
+
+ return true;
+ }
if ( $isOld ) {
$newThumbUrl = $targetFile->getArchiveThumbUrl(
$archiveTimestamp . '!' . $targetFile->getName(),
diff --git a/tests/phpunit/includes/filerepo/ThumbnailEntryPointTest.php b/tests/phpunit/includes/filerepo/ThumbnailEntryPointTest.php
index 4af0b6ceead..1203bf93fb4 100644
--- a/tests/phpunit/includes/filerepo/ThumbnailEntryPointTest.php
+++ b/tests/phpunit/includes/filerepo/ThumbnailEntryPointTest.php
@@ -243,6 +243,38 @@ class ThumbnailEntryPointTest extends MediaWikiIntegrationTestCase {
$env->assertStatusCode( 400, $output );
}
+ /** Verify that the exception from ImageHandler:makeParamString is handled */
+ public function testNoWidth() {
+ $env = $this->makeEnvironment(
+ [
+ 'f' => 'Test.png',
+ // no width
+ ]
+ );
+ $entryPoint = $this->getEntryPoint( $env );
+
+ $entryPoint->run();
+ $output = $entryPoint->getCapturedOutput();
+
+ $env->assertStatusCode( 400, $output );
+ }
+
+ /** Verify that the exception from ImageHandler:makeParamString is handled in redirect case - T387684 */
+ public function testNoWidthRedirect() {
+ $env = $this->makeEnvironment(
+ [
+ 'f' => 'Redirect_to_Test.png',
+ // no width
+ ]
+ );
+ $entryPoint = $this->getEntryPoint( $env );
+
+ $entryPoint->run();
+ $output = $entryPoint->getCapturedOutput();
+
+ $env->assertStatusCode( 400, $output );
+ }
+
public static function provideTransformError() {
yield 'MediaTransformError' => [
new MediaTransformError( 'testing', 200, 100 ),

File Metadata

Mime Type
text/x-diff
Expires
Sat, Jul 5, 5:31 AM (8 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
227438
Default Alt Text
(2 KB)

Event Timeline