From: Aaron Schulz Date: Fri, 25 Nov 2011 02:21:46 +0000 (+0000) Subject: FU r103738: redid the method of getting the source file name for thumbnails altogethe... X-Git-Tag: 1.31.0-rc.0~26299 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=22c5655da3e1d35c0cc651f7a5703b39f6f88121;p=lhc%2Fweb%2Fwiklou.git FU r103738: redid the method of getting the source file name for thumbnails altogether, using suggestion per CR. --- diff --git a/img_auth.php b/img_auth.php index 6dec63f4b4..8b121812f6 100644 --- a/img_auth.php +++ b/img_auth.php @@ -94,12 +94,13 @@ function wfImageAuthMain() { return; } - // Extract the file name and chop off the size specifier + // Extract the file name and chop off the size specifier. // (e.g. 120px-Foo.png => Foo.png or page2-120px-Foo.png => Foo.png). - // This only applies to thumbnails, and all thumbnails have a -px specifier. + // This only applies to thumbnails, and all thumbnails should + // be under a folder that has the source file name. $name = wfBaseName( $path ); - if ( preg_match( '!(?:[^-]*-)*?\d+px-(.*)!i', $name, $m ) ) { - $name = $m[1]; // this file is a thumbnail + if ( strpos( $path, '/thumb/' ) === 0 ) { + $name = wfBaseName( dirname( $path ) ); // this file is a thumbnail } $title = Title::makeTitleSafe( NS_FILE, $name ); @@ -116,7 +117,7 @@ function wfImageAuthMain() { // Check user authorization for this title // UserCanRead Checks Whitelist too - if( !$title->userCanRead() ) { + if ( !$title->userCanRead() ) { wfForbidden( 'img-auth-accessdenied', 'img-auth-noread', $name ); return; }