From 161c28dffcab78da00b6b80693ef9423c4258248 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sat, 05 Sep 2009 08:31:19 -0400
Subject: [PATCH] - Fix wrong headers for IE on servers without $_SERVER['HTTPS'] (#1485926) - Force IE style headers for attachments in non-HTTPS session, 'use_https' option (#1485655)

---
 CHANGELOG                        |    2 ++
 index.php                        |    3 ++-
 program/include/rcube_shared.inc |    2 +-
 program/steps/mail/rss.inc       |    2 +-
 program/lib/imap.inc             |    2 +-
 5 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 8cdd04f..af6306d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
 CHANGELOG RoundCube Webmail
 ===========================
 
+- Fix wrong headers for IE on servers without $_SERVER['HTTPS'] (#1485926)
+- Force IE style headers for attachments in non-HTTPS session, 'use_https' option (#1485655)
 - Check 'post_max_size' for upload max filesize (#1486089) 
 - Password Plugin: Fix %d inserts username instead of domain (#1486088)
 - Fix rcube_mdb2::affected_rows() (#1486082)
diff --git a/index.php b/index.php
index 542a724..fc5926d 100644
--- a/index.php
+++ b/index.php
@@ -64,7 +64,8 @@
 }
 
 // check if https is required (for login) and redirect if necessary
-if ($RCMAIL->config->get('force_https', false) && empty($_SESSION['user_id']) && !(isset($_SERVER['HTTPS']) || $_SERVER['SERVER_PORT'] == 443)) {
+if ($RCMAIL->config->get('force_https', false) && empty($_SESSION['user_id'])
+    && !(isset($_SERVER['HTTPS']) || $_SERVER['SERVER_PORT'] == 443 || $RCMAIL->config->get('use_https'))) {
   header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
   exit;
 }
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index 91db380..85a6105 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -41,7 +41,7 @@
   header("Pragma: no-cache");
   
   // We need to set the following headers to make downloads work using IE in HTTPS mode.
-  if (isset($_SERVER['HTTPS'])) {
+  if (isset($_SERVER['HTTPS']) || rcmail::get_instance()->config->get('use_https')) {
     header('Pragma: ');
     header('Cache-Control: ');
   }
diff --git a/program/lib/imap.inc b/program/lib/imap.inc
index e6b3ce1..02c9bd9 100644
--- a/program/lib/imap.inc
+++ b/program/lib/imap.inc
@@ -620,7 +620,7 @@
 	}
 
 	stream_set_timeout($conn->fp, 10);
-	$line = stream_get_line($conn->fp, 8192, "\r\n");
+	$line = stream_get_line($conn->fp, 8192, "\n");
 
 	if ($my_prefs['debug_mode'] && $line)
 		write_log('imap', 'S: '. $line);
diff --git a/program/steps/mail/rss.inc b/program/steps/mail/rss.inc
index 667a348..2ebd15c 100644
--- a/program/steps/mail/rss.inc
+++ b/program/steps/mail/rss.inc
@@ -30,7 +30,7 @@
 $OUTPUT_TYPE = 'rss';
 
 $webmail_url = 'http';
-if (strstr('HTTPS', $_SERVER['SERVER_PROTOCOL'] )!== FALSE)
+if (strstr('HTTPS', $_SERVER['SERVER_PROTOCOL'] )!== FALSE || $RCMAIL->config->get('use_https'))
   $webmail_url .= 's';
 $webmail_url .= '://'.$_SERVER['SERVER_NAME'];
 if ($_SERVER['SERVER_PORT'] != '80')

--
Gitblit v1.9.1