Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F584965
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
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 3c9cd1c689b..67f6e701385 100644
--- a/tests/phpunit/includes/filerepo/ThumbnailEntryPointTest.php
+++ b/tests/phpunit/includes/filerepo/ThumbnailEntryPointTest.php
@@ -242,6 +242,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
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Jul 5, 5:31 AM (8 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
227437
Default Alt Text
(2 KB)
Attached To
Mode
rMW mediawiki
Attached
Detach File
Event Timeline
Log In to Comment