X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=thumb.php;h=25bca879547109821ac2ec2de52916ba9e70f1ec;hb=7e283d72488a318c57ba4ac64b43ed2198595dec;hp=3b7ff43612bee0a80ca5c1055c242b38f9c795a0;hpb=a13b99ed9707f3f989fd0e0b4d02317f9c463af5;p=lhc%2Fweb%2Fwiklou.git diff --git a/thumb.php b/thumb.php index 3b7ff43612..25bca87954 100644 --- a/thumb.php +++ b/thumb.php @@ -163,7 +163,7 @@ function wfStreamThumb( array $params ) { // Check if the file is hidden if ( $img->isDeleted( File::DELETED_FILE ) ) { - wfThumbError( 404, "The source file '$fileName' does not exist." ); + wfThumbErrorText( 404, "The source file '$fileName' does not exist." ); return; } @@ -213,14 +213,15 @@ function wfStreamThumb( array $params ) { if ( count( $varyHeader ) ) { $response->header( 'Vary: ' . implode( ', ', $varyHeader ) ); } + $response->header( 'Content-Length: 0' ); return; } // If its not a redirect that has a target as a local file, give 404. - wfThumbError( 404, "The source file '$fileName' does not exist." ); + wfThumbErrorText( 404, "The source file '$fileName' does not exist." ); return; } elseif ( $img->getPath() === false ) { - wfThumbError( 500, "The source file '$fileName' is not locally accessible." ); + wfThumbErrorText( 500, "The source file '$fileName' is not locally accessible." ); return; } @@ -282,7 +283,7 @@ function wfStreamThumb( array $params ) { } return; } else { - wfThumbError( 404, "The given path of the specified thumbnail is incorrect; + wfThumbErrorText( 404, "The given path of the specified thumbnail is incorrect; expected '" . $img->getThumbRel( $thumbName ) . "' but got '" . rawurldecode( $rel404 ) . "'." ); return; @@ -309,7 +310,6 @@ function wfStreamThumb( array $params ) { wfThumbError( 500, 'Could not stream the file' ); } else { RequestContext::getMain()->getStats()->timing( 'media.thumbnail.stream', $streamtime ); - wfDebugLog( 'thumbnailaccess', time() . ' ' . $thumbPath . ' ' . ob_get_length() . ' Streamed ' ); } return; } @@ -546,14 +546,26 @@ function wfExtractThumbParams( $file, $params ) { return null; } + +/** + * Output a thumbnail generation error message + * + * @param int $status + * @param string $msg Plain text (will be html escaped) + * @return void + */ +function wfThumbErrorText( $status, $msgText ) { + return wfThumbError( $status, htmlspecialchars( $msgText ) ); +} + /** * Output a thumbnail generation error message * * @param int $status - * @param string $msg HTML + * @param string $msgHtml HTML * @return void */ -function wfThumbError( $status, $msg ) { +function wfThumbError( $status, $msgHtml ) { global $wgShowHostnames; header( 'Cache-Control: no-cache' ); @@ -585,7 +597,7 @@ function wfThumbError( $status, $msg ) {

Error generating thumbnail

-$msg +$msgHtml

$debug