X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=img_auth.php;h=55f17ac7f474e11dc5d6727179af5eafebc964e7;hb=253dbff3224d38c7af0986f949f9b248a3d4e0dc;hp=cce5bc97c032e2d938c289c1d8ee388d5dccb16e;hpb=ca895b7072b9d98a5b3abf8f2a46474095c16210;p=lhc%2Fweb%2Fwiklou.git diff --git a/img_auth.php b/img_auth.php index cce5bc97c0..55f17ac7f4 100644 --- a/img_auth.php +++ b/img_auth.php @@ -12,8 +12,6 @@ * - Set $wgImgAuthDetails = true if you want the reason the access was denied messages to * be displayed instead of just the 403 error (doesn't work on IE anyway), * otherwise it will only appear in error logs - * - Set $wgImgAuthPublicTest false if you don't want to just check and see if all are public - * must be set to false if using specific restrictions such as LockDown or NSFileRepo * * For security reasons, you usually don't want your user to know *why* access was denied, * just that it was. If you want to change this, you can set $wgImgAuthDetails to 'true' @@ -56,18 +54,11 @@ $factory->commitMasterChanges(); $factory->shutdown(); function wfImageAuthMain() { - global $wgImgAuthPublicTest, $wgImgAuthUrlPathMap; + global $wgImgAuthUrlPathMap; $request = RequestContext::getMain()->getRequest(); $publicWiki = in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ); - // See if this is a public Wiki (no protections). - if ( $wgImgAuthPublicTest && $publicWiki ) { - // This is a public wiki, so disable this script (for private wikis only) - wfForbidden( 'img-auth-accessdenied', 'img-auth-public' ); - return; - } - // Get the requested file path (source file or thumbnail) $matches = WebRequest::getPathInfo(); if ( !isset( $matches['title'] ) ) { @@ -82,7 +73,7 @@ function wfImageAuthMain() { // Check for bug 28235: QUERY_STRING overriding the correct extension $whitelist = array(); - $extension = FileBackend::extensionFromPath( $path ); + $extension = FileBackend::extensionFromPath( $path, 'rawcase' ); if ( $extension != '' ) { $whitelist[] = $extension; } @@ -115,14 +106,15 @@ function wfImageAuthMain() { // Get the local file repository $repo = RepoGroup::singleton()->getRepo( 'local' ); + $zone = strstr( ltrim( $path, '/' ), '/', true ); // Get the full file storage path and extract the source file name. // (e.g. 120px-Foo.png => Foo.png or page2-120px-Foo.png => Foo.png). - // This only applies to thumbnails, and all thumbnails should + // This only applies to thumbnails/transcoded, and each of them should // be under a folder that has the source file name. - if ( strpos( $path, '/thumb/' ) === 0 ) { - $name = wfBaseName( dirname( $path ) ); // file is a thumbnail - $filename = $repo->getZonePath( 'thumb' ) . substr( $path, 6 ); // strip "/thumb" + if ( $zone === 'thumb' || $zone === 'transcoded' ) { + $name = wfBaseName( dirname( $path ) ); + $filename = $repo->getZonePath( $zone ) . substr( $path, strlen( "/" . $zone ) ); // Check to see if the file exists if ( !$repo->fileExists( $filename ) ) { wfForbidden( 'img-auth-accessdenied', 'img-auth-nofile', $filename );