r104150 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104149‎ | r104150 | r104151 >
Date:09:55, 24 November 2011
Author:dantman
Status:ok
Tags:
Comment:
Update img_auth.php and WebRequest code to handle non index.php scripts like img_auth.php better.
Also update img_auth.php so it's abuse of $wg variables is done in a way that doesn't let "/*" action paths clobber it's handling.
This should theoretically fix bug 32486.
Modified paths:
  • /trunk/phase3/img_auth.php (modified) (history)
  • /trunk/phase3/includes/WebRequest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/WebRequest.php
@@ -96,6 +96,16 @@
9797 // Raw PATH_INFO style
9898 $matches = self::extractTitle( $path, "$wgScript/$1" );
9999
 100+ if( !$matches
 101+ && isset( $_SERVER['SCRIPT_NAME'] )
 102+ && preg_match( '/\.php5?/', $_SERVER['SCRIPT_NAME'] ) )
 103+ {
 104+ # Check for SCRIPT_NAME, we handle index.php explicitly
 105+ # But we do have some other .php files such as img_auth.php
 106+ # Don't let root article paths clober the parsing for them
 107+ $matches = self::extractTitle( $path, $_SERVER['SCRIPT_NAME'] . "/$1" );
 108+ }
 109+
100110 global $wgArticlePath;
101111 if( !$matches && $wgArticlePath ) {
102112 $matches = self::extractTitle( $path, $wgArticlePath );
Index: trunk/phase3/img_auth.php
@@ -36,7 +36,8 @@
3737
3838 # Set action base paths so that WebRequest::getPathInfo()
3939 # recognizes the "X" as the 'title' in ../image_auth/X urls.
40 -$wgActionPaths[] = $_SERVER['SCRIPT_NAME'];
 40+$wgArticlePath = false; # Don't let a "/*" article path clober our action path
 41+$wgActionPaths = array( "$wgUploadPath/" );
4142
4243 wfImageAuthMain();
4344 wfLogProfilingData();
@@ -55,7 +56,11 @@
5657
5758 // Get the requested file path (source file or thumbnail)
5859 $matches = WebRequest::getPathInfo();
59 - $path = $matches['title']; // path with leading '/'
 60+ $path = $matches['title'];
 61+ if ( $path && $path[0] !== '/' ) {
 62+ // Make sure $path has a leading /
 63+ $path = "/" . $path;
 64+ }
6065
6166 // Check for bug 28235: QUERY_STRING overriding the correct extension
6267 $whitelist = array();

Status & tagging log