X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=thumb.php;h=eb0d67df191badd7d240bdd4506a2699bbbc399a;hb=3e3da50e8ac345a24b0619540966909fc65d7d56;hp=e5fcf3a8b58a7761bb663587a43768a0b94aef03;hpb=8f0814e64c0ae27bda0dc7e0d862fb95f2222d18;p=lhc%2Fweb%2Fwiklou.git diff --git a/thumb.php b/thumb.php index e5fcf3a8b5..eb0d67df19 100644 --- a/thumb.php +++ b/thumb.php @@ -124,7 +124,7 @@ function wfStreamThumb( array $params ) { // Check permissions if there are read restrictions if ( !in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) ) { - if ( !$img->getTitle()->userCan( 'read' ) ) { + if ( !$img->getTitle() || !$img->getTitle()->userCan( 'read' ) ) { wfThumbError( 403, 'Access denied. You do not have permission to access ' . 'the source file.' ); wfProfileOut( __METHOD__ ); @@ -173,6 +173,17 @@ function wfStreamThumb( array $params ) { try { $thumbName = $img->thumbName( $params ); if ( strlen( $thumbName ) ) { // valid params? + // For 404 handled thumbnails, we only use the the base name of the URI + // for the thumb params and the parent directory for the source file name. + // Check that the zone relative path matches up so squid caches won't pick + // up thumbs that would not be purged on source file deletion (bug 34231). + if ( isset( $params['rel404'] ) // thumbnail was handled via 404 + && urldecode( $params['rel404'] ) !== $img->getThumbRel( $thumbName ) ) + { + wfThumbError( 404, 'The source file for the specified thumbnail does not exist.' ); + wfProfileOut( __METHOD__ ); + return; + } $thumbPath = $img->getThumbPath( $thumbName ); if ( $img->getRepo()->fileExists( $thumbPath ) ) { $img->getRepo()->streamFile( $thumbPath, $headers ); @@ -244,23 +255,22 @@ function wfExtractThumbParams( $uri ) { $hashDirRegex .= "$subdirRegex/"; } - $thumbUrlRegex = "!^$zoneUrlRegex(/archive|/temp|)/$hashDirRegex([^/]*)/([^/]*)$!"; + $thumbUrlRegex = "!^$zoneUrlRegex/((archive/|temp/)?$hashDirRegex([^/]*)/([^/]*))$!"; // Check if this is a valid looking thumbnail request... if ( preg_match( $thumbUrlRegex, $uri, $matches ) ) { - list( /* all */, $archOrTemp, $filename, $thumbname ) = $matches; + list( /* all */, $rel, $archOrTemp, $filename, $thumbname ) = $matches; $filename = urldecode( $filename ); $thumbname = urldecode( $thumbname ); - $params = array( 'f' => $filename ); - if ( $archOrTemp == '/archive' ) { + $params = array( 'f' => $filename, 'rel404' => $rel ); + if ( $archOrTemp == 'archive/' ) { $params['archived'] = 1; - } elseif ( $archOrTemp == '/temp' ) { + } elseif ( $archOrTemp == 'temp/' ) { $params['temp'] = 1; } // Check if the parameters can be extracted from the thumbnail name... - // @TODO: remove 'page' stuff and make ProofreadPage handle it via hook. if ( preg_match( '!^(page(\d*)-)*(\d*)px-[^/]*$!', $thumbname, $matches ) ) { list( /* all */, $pagefull, $pagenum, $size ) = $matches; $params['width'] = $size;