stylize.php changes.
[lhc/web/wiklou.git] / img_auth.php
index 5ac5699..9b330ce 100644 (file)
@@ -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();
 
 /**