From: Tim Starling Date: Sat, 12 May 2007 15:44:54 +0000 (+0000) Subject: Use $_SERVER['REQUEST_URI'] instead of $_SERVER['PATH_INFO'], because Apache 2.x... X-Git-Tag: 1.31.0-rc.0~52938 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=cb5aecf73e867e2d24de535c9f20bf5ecef1c875;p=lhc%2Fweb%2Fwiklou.git Use $_SERVER['REQUEST_URI'] instead of $_SERVER['PATH_INFO'], because Apache 2.x corrupts the latter. Idea came from trac.agavi.org/ticket/502 . --- diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 53273a22e1..f8e3c72597 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -46,14 +46,31 @@ class WebRequest { $this->checkMagicQuotes(); global $wgUsePathInfo; if ( $wgUsePathInfo ) { - if ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER['ORIG_PATH_INFO'] != '' ) { + // PATH_INFO is mangled due to http://bugs.php.net/bug.php?id=31892 + // And also by Apache 2.x, double slashes are converted to single slashes. + // So we will use REQUEST_URI if possible. + $title = ''; + if ( !empty( $_SERVER['REQUEST_URI'] ) ) { + global $wgArticlePath; + $url = $_SERVER['REQUEST_URI']; + if ( !preg_match( '!^https?://!', $url ) ) { + $url = 'http://unused' . $url; + } + $a = parse_url( $url ); + // Find the part after $wgArticlePath + $base = str_replace( '$1', '', $wgArticlePath ); + if ( $a && substr( $a['path'], 0, strlen( $base ) ) == $base ) { + $title = substr( $a['path'], strlen( $base ) ); + } + } elseif ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER['ORIG_PATH_INFO'] != '' ) { # Mangled PATH_INFO # http://bugs.php.net/bug.php?id=31892 # Also reported when ini_get('cgi.fix_pathinfo')==false - $_GET['title'] = $_REQUEST['title'] = substr( $_SERVER['ORIG_PATH_INFO'], 1 ); + $title = substr( $_SERVER['ORIG_PATH_INFO'], 1 ); } elseif ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != '') && $wgUsePathInfo ) { - $_GET['title'] = $_REQUEST['title'] = substr( $_SERVER['PATH_INFO'], 1 ); + $title = substr( $_SERVER['PATH_INFO'], 1 ); } + $_GET['title'] = $_REQUEST['title'] = $title; } }