Fixes wrong anchor if php and path omitted
authorAlexander Ebert <ebert@woltlab.com>
Tue, 28 Feb 2012 02:50:32 +0000 (03:50 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 28 Feb 2012 02:50:32 +0000 (03:50 +0100)
Fixes #458

wcfsetup/install/files/lib/system/WCF.class.php

index ac8d36d9a29227825b63dddc5a8ccc5e91ffa2b4..bd99513636119c36698cd8df534b719ccb012149 100644 (file)
@@ -631,7 +631,13 @@ class WCF {
         */
        public function getAnchor($fragment) {
                // resolve path and query components
-               $path = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['REQUEST_URI']);
+               $scriptName = $_SERVER['SCRIPT_NAME'];
+               if (empty($_SERVER['PATH_INFO'])) {
+                       // bug fix if URL omits script name and path
+                       $scriptName = substr($scriptName, 0, strrpos($scriptName, '/'));
+               }
+               
+               $path = str_replace($scriptName, '', $_SERVER['REQUEST_URI']);
                $baseHref = self::getTPL()->get('baseHref');
                
                return $baseHref . 'index.php' . $path . '#' . $fragment;