From 5f58127eae9ed8c54c190506e11af13e8ba57170 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sun, 24 Aug 2014 05:43:12 -0400
Subject: [PATCH] Added rcube_utils::resolve_url()

---
 program/include/rcmail.php |   25 ++++++++-----------------
 1 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 52b53e9..ece0606 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -827,26 +827,17 @@
         }
 
         if ($absolute || $full) {
-            $prefix = '';
-
-            // prepend protocol://hostname:port
-            if ($full) {
-                $schema = 'http';
-                $default_port = 80;
-                if (rcube_utils::https_check()) {
-                    $schema = 'https';
-                    $default_port = 443;
-                }
-                $prefix = $schema . '://' . preg_replace('/:\d+$/', '', $_SERVER['HTTP_HOST']);
-                if ($_SERVER['SERVER_PORT'] != $default_port) {
-                  $prefix .= ':' . $_SERVER['SERVER_PORT'];
-                }
-            }
-
             // add base path to this Roundcube installation
             $base_path = preg_replace('![^/]+$!', '', strval($_SERVER['SCRIPT_NAME']));
             if ($base_path == '') $base_path = '/';
-            $prefix .= $base_path;
+            $prefix = $base_path;
+
+            // prepend protocol://hostname:port
+            if ($full) {
+                $prefix = rcube_utils::resolve_url($prefix);
+            }
+
+            $prefix = rtrim($prefix, '/') . '/';
         }
         else {
             $prefix = './';

--
Gitblit v1.9.1