From: Alexander Ebert Date: Tue, 28 Feb 2012 02:50:32 +0000 (+0100) Subject: Fixes wrong anchor if php and path omitted X-Git-Tag: 2.0.0_Beta_1~1298 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=257d1571378911d6bdc8178f7f90be889396e610;p=GitHub%2FWoltLab%2FWCF.git Fixes wrong anchor if php and path omitted Fixes #458 --- diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index ac8d36d9a2..bd99513636 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -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;