X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=img_auth.php;h=9b330ce2d4543bf124e60a08a36b167e746208a7;hb=04e002d5823dbb63cdd52bb235846fd08d433585;hp=5ac56999f566f5d0ede1ec5fc112155faded1e09;hpb=ff1dc8a17591c1e540d6f7e2ccb5c1ba0dec2e34;p=lhc%2Fweb%2Fwiklou.git diff --git a/img_auth.php b/img_auth.php index 5ac56999f5..9b330ce2d4 100644 --- a/img_auth.php +++ b/img_auth.php @@ -32,7 +32,6 @@ if ( isset( $_SERVER['MW_COMPILED'] ) ) { 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) @@ -42,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( '/\.[^\\/:*?"<>|%]+(#|\?|$)/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 ); @@ -90,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(); /**