r22129 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22128‎ | r22129 | r22130 >
Date:19:25, 12 May 2007
Author:tstarling
Status:old
Tags:
Comment:
a couple of fixes
Modified paths:
  • /trunk/phase3/includes/WebRequest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/WebRequest.php
@@ -46,14 +46,33 @@
4747 $this->checkMagicQuotes();
4848 global $wgUsePathInfo;
4949 if ( $wgUsePathInfo ) {
50 - if ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER['ORIG_PATH_INFO'] != '' ) {
 50+ // PATH_INFO is mangled due to http://bugs.php.net/bug.php?id=31892
 51+ // And also by Apache 2.x, double slashes are converted to single slashes.
 52+ // So we will use REQUEST_URI if possible.
 53+ $title = '';
 54+ if ( !empty( $_SERVER['REQUEST_URI'] ) ) {
 55+ global $wgArticlePath;
 56+ $url = $_SERVER['REQUEST_URI'];
 57+ if ( !preg_match( '!^https?://!', $url ) ) {
 58+ $url = 'http://unused' . $url;
 59+ }
 60+ $a = parse_url( $url );
 61+ // Find the part after $wgArticlePath
 62+ $base = str_replace( '$1', '', $wgArticlePath );
 63+ if ( $a && substr( $a['path'], 0, strlen( $base ) ) == $base ) {
 64+ $title = urldecode( substr( $a['path'], strlen( $base ) ) );
 65+ }
 66+ } elseif ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER['ORIG_PATH_INFO'] != '' ) {
5167 # Mangled PATH_INFO
5268 # http://bugs.php.net/bug.php?id=31892
5369 # Also reported when ini_get('cgi.fix_pathinfo')==false
54 - $_GET['title'] = $_REQUEST['title'] = substr( $_SERVER['ORIG_PATH_INFO'], 1 );
 70+ $title = substr( $_SERVER['ORIG_PATH_INFO'], 1 );
5571 } elseif ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != '') && $wgUsePathInfo ) {
56 - $_GET['title'] = $_REQUEST['title'] = substr( $_SERVER['PATH_INFO'], 1 );
 72+ $title = substr( $_SERVER['PATH_INFO'], 1 );
5773 }
 74+ if ( strval( $title ) != '' ) {
 75+ $_GET['title'] = $_REQUEST['title'] = $title;
 76+ }
5877 }
5978 }
6079