Hotfix for fixing URL generation on dev.horde.org.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 10 Oct 2010 20:25:28 +0000 (16:25 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 10 Oct 2010 20:25:28 +0000 (16:25 -0400)
Commit 043b05f09f66a78566fb broke url generation when an app's webroot
is an absolute url like e.g., http://git.horde.org on simon.

This can probably be tweaked a bit later, but this fixes the immediate issue.

framework/Core/lib/Horde.php

index 13e297c..6b31896 100644 (file)
@@ -919,8 +919,9 @@ HTML;
 
         $puri = parse_url($uri);
         $url = '';
+        $webroot = ltrim($GLOBALS['registry']->get('webroot', empty($opts['app']) ? null : $opts['app']), '/');
 
-        if ($full && !isset($puri['scheme'])) {
+        if ($full && !isset($puri['scheme']) && !preg_match('|^([\w+-]{1,20})://|', $webroot) ) {
             /* Store connection parameters in local variables. */
             $server_name = $GLOBALS['conf']['server']['name'];
             $server_port = $GLOBALS['conf']['server']['port'];
@@ -955,10 +956,11 @@ HTML;
             $url = $protocol . '://' . $server_name;
         }
 
-        if (isset($puri['path']) && substr($puri['path'], 0, 1) == '/') {
+        if (isset($puri['path']) && substr($puri['path'], 0, 1) == '/' && !preg_match('|^([\w+-]{1,20})://|', $webroot)) {
             $url .= $puri['path'];
+        } elseif (isset($puri['path']) && preg_match('|^([\w+-]{1,20})://|', $webroot)) {
+            $url = $webroot . (substr($puri['path'], 0, 1) != '/' ? '/' : '') . $puri['path'];
         } else {
-            $webroot = ltrim($GLOBALS['registry']->get('webroot', empty($opts['app']) ? null : $opts['app']), '/');
             $url .= '/' . ($webroot ? $webroot . '/' : '') . (isset($puri['path']) ? $puri['path'] : '');
         }