diff --git a/lib/setuplib.php b/lib/setuplib.php index 929ad2ef8e7..5debbd71ea0 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -883,11 +883,19 @@ function setup_get_remote_url() { //IIS - needs a lot of tweaking to make it work $rurl['fullpath'] = $_SERVER['SCRIPT_NAME']; - // NOTE: ignore PATH_INFO because it is incorrectly encoded using 8bit filesystem legacy encoding in IIS - // since 2.0 we rely on iis rewrite extenssion like Helicon ISAPI_rewrite - // example rule: RewriteRule ^([^\?]+?\.php)(\/.+)$ $1\?file=$2 [QSA] + // NOTE: we should ignore PATH_INFO because it is incorrectly encoded using 8bit filesystem legacy encoding in IIS. + // Since 2.0, we rely on IIS rewrite extensions like Helicon ISAPI_rewrite + // example rule: RewriteRule ^([^\?]+?\.php)(\/.+)$ $1\?file=$2 [QSA] + // OR + // we rely on a proper IIS 6.0+ configuration: the 'FastCGIUtf8ServerVariables' registry key. + if (isset($_SERVER['PATH_INFO']) and $_SERVER['PATH_INFO'] !== '') { + // Check that PATH_INFO works == must not contain the script name. + if (strpos($_SERVER['PATH_INFO'], $_SERVER['SCRIPT_NAME']) === false) { + $rurl['fullpath'] .= clean_param(urldecode($_SERVER['PATH_INFO']), PARAM_PATH); + } + } - if ($_SERVER['QUERY_STRING'] != '') { + if (isset($_SERVER['QUERY_STRING']) and $_SERVER['QUERY_STRING'] !== '') { $rurl['fullpath'] .= '?'.$_SERVER['QUERY_STRING']; } $_SERVER['REQUEST_URI'] = $rurl['fullpath']; // extra IIS compatibility diff --git a/lib/weblib.php b/lib/weblib.php index abeb2050fc3..89a0f142864 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1030,9 +1030,11 @@ function get_file_argument() { // Then try extract file from the slasharguments. if (stripos($_SERVER['SERVER_SOFTWARE'], 'iis') !== false) { - // NOTE: ISS tends to convert all file paths to single byte DOS encoding, + // NOTE: IIS tends to convert all file paths to single byte DOS encoding, // we can not use other methods because they break unicode chars, - // the only way is to use URL rewriting. + // the only ways are to use URL rewriting + // OR + // to properly set the 'FastCGIUtf8ServerVariables' registry key. if (isset($_SERVER['PATH_INFO']) and $_SERVER['PATH_INFO'] !== '') { // Check that PATH_INFO works == must not contain the script name. if (strpos($_SERVER['PATH_INFO'], $SCRIPT) === false) {