roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.78k stars 1.62k forks source link

Can't display attachment with IE. #1854

Closed rcubetrac closed 15 years ago

rcubetrac commented 15 years ago

Reported by dwj on 4 Oct 2008 09:10 UTC as Trac ticket #1485449

I am using 0.2 beta svn version. It's all ok with Firefox, but can't display attachment(pdf/word/execl) files with IE.

I checked the code, it's send_nocacheing_headers() cause IE always delete the file after download completed.

Here is my code to fix the bug.

Modify program/include/rcube_shared.inc

function send_nocacheing_headers()
{
  if (headers_sent())
    return;

  if (strstr($_SERVER['HTTP_USER_AGENT'], MSIE))
  {
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-Transfer-Encoding: binary");
    header("Pragma: public");
  }
  else
  {
    header("Cache-Control: private");
    header("Content-Transfer-Encoding: binary");
    header("Expires: 0");
    header("Pragma: no-cache");
  }
}

Migrated-From: http://trac.roundcube.net/ticket/1485449

rcubetrac commented 15 years ago

Comment by tensor on 4 Oct 2008 11:21 UTC

Cannot reproduce this. I tested with .doc and .docx files with IR 7 on Windows XP SP3 fully patched.

Dwj, please provide more info.

  1. Your distro and php version, version of Windows and version of IE (in Help->About). Are you using HTTPS?
  2. Try to create a new user in Windows and try to reproduce the bug in fresh account, some IE settings may be at play.

Please provide a patch aginst the latest version in svn trunk.

rcubetrac commented 15 years ago

Milestone changed by tensor on 4 Oct 2008 11:21 UTC

later => 0.2-stable

rcubetrac commented 15 years ago

Comment by tensor on 4 Oct 2008 11:21 UTC

I really mean IE 7, not IR 7 :)

rcubetrac commented 15 years ago

Comment by dwj on 4 Oct 2008 17:42 UTC

I run RC on ubuntu 8.04 with Apache 2.2.8, libapache2-mod-php 5.2.4, no https. Client is Windows XP SP3 fully patched with IE6.1 and IE7.

I tested to view a .pdf attachment file. IE7 says that it can't find the file after download completed.

Patch is here

--- rcube_shared.inc    2008-10-05 01:19:16.000000000 +0800
+++ rcube_shared.inc.new        2008-10-05 01:26:09.000000000 +0800
@@ -35,15 +35,19 @@
   if (headers_sent())
     return;

-  header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");
-  header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
-  header("Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
-  header("Pragma: no-cache");
-
-  // We need to set the following headers to make downloads work using IE in HTTPS mode.
-  if (isset($_SERVER[{
-    header('Pragma: ');
-    header('Cache-Control: ');
+  if (strstr($_SERVER['HTTP_USER_AGENT']('HTTPS']))), MSIE))
+  {
+    header("Expires: 0");
+    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
+    header("Content-Transfer-Encoding: binary");
+    header("Pragma: public");
+  }
+  else
+  {
+    header("Cache-Control: private");
+    header("Content-Transfer-Encoding: binary");
+    header("Expires: 0");
+    header("Pragma: no-cache");
   }
 }

You can see the issue in comments of http://joseph.randomnetworks.com/archives/2004/10/01/making-ie-accept-file-downloads/

rcubetrac commented 15 years ago

Comment by tensor on 4 Oct 2008 19:37 UTC

Replying to dwj:

I run RC on ubuntu 8.04 with Apache 2.2.8, libapache2-mod-php 5.2.4, no https. Client is Windows XP SP3 fully patched with IE6.1 and IE7. Do you use something like multiIE?

rcubetrac commented 15 years ago

Comment by dwj on 5 Oct 2008 03:48 UTC

Replying to tensor:

Replying to dwj:

I run RC on ubuntu 8.04 with Apache 2.2.8, libapache2-mod-php 5.2.4, no https. Client is Windows XP SP3 fully patched with IE6.1 and IE7. Do you use something like multiIE?

No, I didn't use multiIE. My desktop pc is IE7 environment, and run XP SP3 IE6 on virtualbox for testing.

rcubetrac commented 15 years ago

Comment by tensor on 5 Oct 2008 03:54 UTC

Can you provide a test account on your server? You can send me private details to dennis at nikolaenko dot ru

rcubetrac commented 15 years ago

Comment by tensor on 6 Oct 2008 20:14 UTC

Please try the following patch:

=== program/steps/mail/get.inc
==================================================================
--- program/steps/mail/get.inc  (revision 2016)
+++ program/steps/mail/get.inc  (local)
@@ -89,7 +89,6 @@
       }

       $filename = $part->filename ? $part->filename : ($MESSAGE->subject ? $MESSAGE->subject : 'roundcube') . '.'.$ctype_secondary;
-      $filename = abbreviate_string($part->filename, 55);
       $filename = $browser->ie ? rawurlencode($filename) : addslashes($filename);
       $disposition = !empty($_GET['_download']) ? 'attachment' : 'inline';
rcubetrac commented 15 years ago

Comment by adamg on 16 Oct 2008 18:09 UTC

I've run into the same issue, with Internet Explorer 6.5/7.0 PDF attachments weren't displayed, instead they resulted in an "Internet explorer cannot download" error message. With some help of git-svn, I've narrowed this down to changeset [then down change to program/steps/mail/get.inc, and finally down to single line:

-    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");

Turns out, when there's either "Cache-control: no-cache" or "Cache-Control: no-store" http header set, IE will fail to open PDF/DOC/XLS inline. There's an article available in Microsoft Knowledge Base: http://support.microsoft.com/kb/812935 that discusses this issue.

I've prepared simple one-liner that fixes current trunk (b685e9e4(0dbac321],) at the moment). Please apply the below patch:

--- roundcube.svn/program/include/rcube_shared.inc~     2008-10-13 07:37:09.000000000 +0200
+++ roundcube.svn/program/include/rcube_shared.inc      2008-10-16 20:00:01.000000000 +0200
@@ -37,7 +37,7 @@

   header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");
   header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
-  header("Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
+  header("Cache-Control: private, must-revalidate, post-check=0, pre-check=0");
   header("Pragma: no-cache");

   // We need to set the following headers to make downloads work using IE in HTTPS mode.
rcubetrac commented 15 years ago

Comment by @thomascube on 23 Nov 2008 14:56 UTC

Last patch added in 456c7e40. Does this solve the issue now? Please re-open if it's not solved with this.

rcubetrac commented 15 years ago

Status changed by @thomascube on 23 Nov 2008 14:56 UTC

new => closed