X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=img_auth.php;h=8ea7b01a7ba65860917c8ce7011e59064e54cf92;hb=68e241b663426eaf35d7dec506520aa7fec30a46;hp=c9a224205963bf8177c14d184d2ebb8c811fd397;hpb=3ef857fe4d25c9e5cfd4d73718988df591cf885d;p=lhc%2Fweb%2Fwiklou.git diff --git a/img_auth.php b/img_auth.php index c9a2242059..8ea7b01a7b 100644 --- a/img_auth.php +++ b/img_auth.php @@ -26,7 +26,11 @@ **/ 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' ); @@ -38,15 +42,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-z]{1,4}$/i', $_SERVER['QUERY_STRING'] ) ) +$dotPos = strpos( $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 );