Index: trunk/phase3/includes/WebRequest.php |
— | — | @@ -46,14 +46,31 @@ |
47 | 47 | $this->checkMagicQuotes(); |
48 | 48 | global $wgUsePathInfo; |
49 | 49 | 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 = substr( $a['path'], strlen( $base ) ); |
| 65 | + } |
| 66 | + } elseif ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER['ORIG_PATH_INFO'] != '' ) { |
51 | 67 | # Mangled PATH_INFO |
52 | 68 | # http://bugs.php.net/bug.php?id=31892 |
53 | 69 | # 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 ); |
55 | 71 | } 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 ); |
57 | 73 | } |
| 74 | + $_GET['title'] = $_REQUEST['title'] = $title; |
58 | 75 | } |
59 | 76 | } |
60 | 77 | |