Work-around for IIS URL-Rewrite-Module messing up the encoding
authorAlexander Ebert <ebert@woltlab.com>
Wed, 11 Mar 2015 17:05:28 +0000 (18:05 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 11 Mar 2015 17:05:28 +0000 (18:05 +0100)
There is a known bug which causes REQUEST_URI to be ISO-encoded, even though there is a hotfix enabled, certain Plesk versions do not ship that fix. Since it is safe to rely on UNENCODED_URL, we'll fall back to this one.

wcfsetup/install/files/lib/page/AbstractPage.class.php

index a729fed915e77388cd5d28ba74d8bfaa969efb5a..2e66ce275fa7d181858bc8c7dc99cf783916cdd5 100644 (file)
@@ -185,7 +185,10 @@ abstract class AbstractPage implements IPage, ITrackablePage {
                        $canoncialURL = parse_url(preg_replace('~[?&]s=[a-f0-9]{40}~', '', $this->canonicalURL));
                        
                        // use $_SERVER['REQUEST_URI'] because it represents the URL used to access the site and not the internally rewritten one
-                       $requestURI = preg_replace('~[?&]s=[a-f0-9]{40}~', '', $_SERVER['REQUEST_URI']);
+                       // IIS Rewrite-Module has a bug causing the REQUEST_URI to be ISO-encoded
+                       $requestURI = (!empty($_SERVER['UNENCODED_URL'])) ? $_SERVER['UNENCODED_URL'] : $_SERVER['REQUEST_URI'];
+                       $requestURI = preg_replace('~[?&]s=[a-f0-9]{40}~', '', $requestURI);
+                       
                        if (!StringUtil::isUTF8($requestURI)) {
                                $requestURI = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $requestURI);
                        }