X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=img_auth.php;h=ed4c6be4b3d695a879350c8f9114688984df55b2;hb=df2306b971a21c7a7b33696f836beabe7961f1bf;hp=5ac56999f566f5d0ede1ec5fc112155faded1e09;hpb=ff1dc8a17591c1e540d6f7e2ccb5c1ba0dec2e34;p=lhc%2Fweb%2Fwiklou.git diff --git a/img_auth.php b/img_auth.php index 5ac56999f5..ed4c6be4b3 100644 --- a/img_auth.php +++ b/img_auth.php @@ -42,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( '/\.[^\\/:*?"<>|%]+(#|\?|$)/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 );