X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=img_auth.php;h=9b330ce2d4543bf124e60a08a36b167e746208a7;hb=7d5c9504b5d78f4c39286da890c680fab1583a59;hp=7b7bbda2e4940a4977940121790adae8bff416b5;hpb=7aeb423a6e1b0548a433ad0c2205563464f3f0c8;p=lhc%2Fweb%2Fwiklou.git diff --git a/img_auth.php b/img_auth.php index 7b7bbda2e4..9b330ce2d4 100644 --- a/img_auth.php +++ b/img_auth.php @@ -26,9 +26,12 @@ **/ define( 'MW_NO_OUTPUT_COMPRESSION', 1 ); -require_once( dirname( __FILE__ ) . '/includes/WebStart.php' ); +if ( isset( $_SERVER['MW_COMPILED'] ) ) { + require ( 'phase3/includes/WebStart.php' ); +} else { + require ( dirname( __FILE__ ) . '/includes/WebStart.php' ); +} wfProfileIn( 'img_auth.php' ); -require_once( dirname( __FILE__ ) . '/includes/StreamFile.php' ); $wgActionPaths[] = $_SERVER['SCRIPT_NAME']; // See if this is a public Wiki (no protections) @@ -38,15 +41,20 @@ if ( $wgImgAuthPublicTest wfForbidden('img-auth-accessdenied','img-auth-public'); } +$matches = WebRequest::getPathInfo(); +$path = $matches['title']; + // Check for bug 28235: QUERY_STRING overriding the correct extension -if ( isset( $_SERVER['QUERY_STRING'] ) - && preg_match( '/\.[a-z0-9]{1,4}(#|\?|$)/i', $_SERVER['QUERY_STRING'] ) ) +$dotPos = strrpos( $path, '.' ); +$whitelist = array(); +if ( $dotPos !== false ) { + $whitelist[] = substr( $path, $dotPos + 1 ); +} +if ( !$wgRequest->checkUrlExtension( $whitelist ) ) { - wfForbidden( 'img-auth-accessdenied', 'img-auth-bad-query-string' ); -} + return; +} -$matches = WebRequest::getPathInfo(); -$path = $matches['title']; $filename = realpath( $wgUploadDirectory . $path ); $realUpload = realpath( $wgUploadDirectory ); @@ -86,7 +94,7 @@ if( !$title->userCanRead() ) // Stream the requested file wfDebugLog( 'img_auth', "Streaming `".$filename."`." ); -wfStreamFile( $filename, array( 'Cache-Control: private', 'Vary: Cookie' ) ); +StreamFile::stream( $filename, array( 'Cache-Control: private', 'Vary: Cookie' ) ); wfLogProfilingData(); /**