Self revert r89797: At least the block log link is wrong. I should not commit when...
[lhc/web/wiklou.git] / img_auth.php
index c9a2242..8ea7b01 100644 (file)
  **/
 
 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 );