@@ -81,24 +81,21 @@ public function createHttpRequest()
8181 }
8282
8383 // path & query
84- $ requestUrl = isset ($ _SERVER ['REQUEST_URI ' ]) ? $ _SERVER ['REQUEST_URI ' ] : '' ;
84+ $ requestUrl = isset ($ _SERVER ['REQUEST_URI ' ]) ? $ _SERVER ['REQUEST_URI ' ] : '/ ' ;
8585 $ requestUrl = Strings::replace ($ requestUrl , $ this ->urlFilters ['url ' ]);
8686 $ tmp = explode ('? ' , $ requestUrl , 2 );
8787 $ path = Strings::fixEncoding (Strings::replace ($ tmp [0 ], $ this ->urlFilters ['path ' ]));
8888 $ url ->setPath ($ path );
8989 $ url ->setQuery (isset ($ tmp [1 ]) ? $ tmp [1 ] : '' );
9090
9191 // detect script path
92- $ path .= '/ ' ;
93- $ script = isset ($ _SERVER ['SCRIPT_NAME ' ]) ? $ _SERVER ['SCRIPT_NAME ' ] . '/ ' : '/ ' ;
94- $ max = min (strlen ($ path ), strlen ($ script ));
95- for ($ i = 0 ; $ i < $ max ; $ i ++) {
96- if ($ path [$ i ] !== $ script [$ i ]) {
97- break ;
98- } elseif ($ path [$ i ] === '/ ' ) {
99- $ url ->setScriptPath (substr ($ url ->getPath (), 0 , $ i + 1 ));
100- }
92+ $ script = isset ($ _SERVER ['SCRIPT_NAME ' ]) ? $ _SERVER ['SCRIPT_NAME ' ] : '' ;
93+ if ($ path !== $ script ) {
94+ $ max = min (strlen ($ path ), strlen ($ script ));
95+ for ($ i = 0 ; $ i < $ max && $ path [$ i ] === $ script [$ i ]; $ i ++);
96+ $ path = $ i ? substr ($ path , 0 , strrpos ($ path , '/ ' , $ i - $ max - 1 ) + 1 ) : '/ ' ;
10197 }
98+ $ url ->setScriptPath ($ path );
10299
103100 // GET, POST, COOKIE
104101 $ useFilter = (!in_array (ini_get ('filter.default ' ), array ('' , 'unsafe_raw ' )) || ini_get ('filter.default_flags ' ));
0 commit comments