Set content type on error messages, and include a trailing newline
[lhc/web/wiklou.git] / thumb.php
index 4ec40dc..c325d07 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -54,12 +54,17 @@ require_once( 'Setup.php' );
 wfProfileIn( 'thumb.php-render' );
 
 $img = Image::newFromName( $fileName );
-if ( $img ) {
-       if ( ! is_null( $page ) ) {
-               $img->selectPage( $page );
+try {
+       if ( $img ) {
+               if ( ! is_null( $page ) ) {
+                       $img->selectPage( $page );
+               }
+               $thumb = $img->renderThumb( $width, false );
+       } else {
+               $thumb = false;
        }
-       $thumb = $img->renderThumb( $width, false );
-} else {
+} catch( Exception $ex ) {
+       // Tried to select a page on a non-paged file?
        $thumb = false;
 }
 
@@ -68,12 +73,15 @@ if ( $thumb && $thumb->path ) {
 } else {
        $badtitle = wfMsg( 'badtitle' );
        $badtitletext = wfMsg( 'badtitletext' );
+       header( 'Cache-Control: no-cache' );
+       header( 'Content-Type: text/html' );
        echo "<html><head>
        <title>$badtitle</title>
        <body>
 <h1>$badtitle</h1>
 <p>$badtitletext</p>
-</body></html>";
+</body></html>
+";
 }
 
 wfProfileOut( 'thumb.php-render' );