* Don't list sp:ChangeEmail/sp:ChangePassword at SpecialPages. These were clutter...
[lhc/web/wiklou.git] / img_auth.php
index d9b4a78..9b330ce 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' );
 
+$wgActionPaths[] = $_SERVER['SCRIPT_NAME'];
 // See if this is a public Wiki (no protections)
 if ( $wgImgAuthPublicTest
        && in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) )
@@ -37,15 +41,18 @@ if ( $wgImgAuthPublicTest
        wfForbidden('img-auth-accessdenied','img-auth-public');
 }
 
-// Extract path and image information
-if( !isset( $_SERVER['PATH_INFO'] ) ) {
-       $path = $wgRequest->getText( 'path' );
-       if( !$path ) {
-               wfForbidden( 'img-auth-accessdenied', 'img-auth-nopathinfo' );
-       }
-       $path = "/$path";
-} else {
-       $path = $_SERVER['PATH_INFO'];
+$matches = WebRequest::getPathInfo();
+$path = $matches['title'];
+
+// Check for bug 28235: QUERY_STRING overriding the correct extension
+$dotPos = strrpos( $path, '.' );
+$whitelist = array();
+if ( $dotPos !== false ) {
+       $whitelist[] = substr( $path, $dotPos + 1 );
+}
+if ( !$wgRequest->checkUrlExtension( $whitelist ) )
+{
+       return;
 }
 
 $filename = realpath( $wgUploadDirectory . $path );
@@ -87,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();
 
 /**