From 8b5038befcccc29bdf8ea1f0f5745277e87e072f Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Mon, 29 Sep 2014 05:22:38 -0400
Subject: [PATCH] Fix handling of smart list inputs

---
 program/include/rcmail.php |   33 +++++++++++++--------------------
 1 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 52b53e9..e1a6276 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -116,11 +116,13 @@
             $_SESSION['task'] = $this->task;
         }
 
-        // init output class
-        if (!empty($_REQUEST['_remote']))
+        // init output class (not in CLI mode)
+        if (!empty($_REQUEST['_remote'])) {
             $GLOBALS['OUTPUT'] = $this->json_init();
-        else
+        }
+        else if ($_SERVER['REMOTE_ADDR']) {
             $GLOBALS['OUTPUT'] = $this->load_gui(!empty($_REQUEST['_framed']));
+        }
 
         // load plugins
         $this->plugins->init($this, $this->task);
@@ -827,26 +829,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