From 043b05f09f66a78566fbaf27113c408cfd7a0807 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 2 Sep 2010 10:33:46 -0600 Subject: [PATCH] Bug #9161: More tweaking of new Horde::url() --- framework/Core/lib/Horde.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/framework/Core/lib/Horde.php b/framework/Core/lib/Horde.php index d2a750d8a..ee7a6db62 100644 --- a/framework/Core/lib/Horde.php +++ b/framework/Core/lib/Horde.php @@ -916,11 +916,10 @@ HTML; $opts = array(); } + $puri = parse_url($uri); $url = ''; - $webroot = $GLOBALS['registry']->get('webroot', empty($opts['app']) ? null : $opts['app']); - /* Skip if we already have a full URL. */ - if ($full && !preg_match('|^([\w+-]{1,20})://|', $webroot)) { + if ($full && !isset($puri['scheme'])) { /* Store connection parameters in local variables. */ $server_name = $GLOBALS['conf']['server']['name']; $server_port = $GLOBALS['conf']['server']['port']; @@ -952,18 +951,15 @@ HTML; $server_name .= ':' . $server_port; } - /* Don't prepend to webroot if it's already absolute. */ $url = $protocol . '://' . $server_name; - } elseif (!$full && - !empty($_SERVER['HTTP_HOST']) && - preg_match('|^([\w+-]{1,20}://' . preg_quote($_SERVER['HTTP_HOST'], '|') . ')/|', $uri, $matches)) { - // Don't generate absolute URLs if we don't have to. - $uri = substr($uri, strlen($matches[1])); } - $url .= (substr($uri, 0, 1) == '/') - ? $uri - : '/' . ltrim($webroot, '/') . '/' . $uri; + if ($puri['path'][0] == '/') { + $url .= $puri['path']; + } else { + $webroot = $GLOBALS['registry']->get('webroot', empty($opts['app']) ? null : $opts['app']); + $url .= '/' . ltrim($webroot, '/') . '/' . $puri['path']; + } $ob = new Horde_Url($url, $full); -- 2.11.0