Our setup: Windows 2000 Server ; Apache 2.0.61 ; PHP 5.2.5 ; MySQL 5.0.45 ; Drupal 5.6 ; private file system.

We use the core 'Upload' module to manage attachments that we offer for downloading on our web site. Since a few Drupal releases, people using Internet Explorer 6 have experienced problems downloading ZIP files. The problem only shows up when, after clicking on the download link, the person selects "Open file" in the window that pops up. The ZIP file then shows up as being empty with no file inside. When selecting "Save as...", saving the file somewhere on the hard disk and then opening the ZIP file from there, it works OK.

I have run some tests, with the following combinations of OSes and web browsers, in each case selecting the direct "Open file" option after having clicked on the file download link:

1) Windows 2000 + Internet Explorer 6 + Winzip 8.1 SR1: fails
2) Windows XP + Firefox 2.0.0.11 + Winzip 8.1 SR1: works OK
3) Windows XP + Opera 9.25 + Winzip 8.1 SR1: works OK
4) Windows XP + Safari 3.0.4 + Winzip 8.1 SR1: works OK
5) Windows XP + Internet Explorer 6 + Winzip 8.1 SR1: fails
6) Windows XP + Internet Explorer 7 + Winzip 8.1 SR1: works OK
7) Windows Vista + Internet Explorer 7 + built-in feature to open compressed folders: works OK
8) Windows Server 2003 + Internet Explorer 7 + Winzip 8.1 SR1: works OK

The results are the same with either clean URLs turned on or off.

Having access to another server, I have conducted a quick test with the following setup: OpenBSD 4.2 server ; Apache 1.3.19 ; php 5.2.3 ; MySQL 5.0.45 ; Drupal 5.6 ; private file system ; Clean URLs.

=> same results with Windows XP + Internet Explorer 6 + Winzip 8.1 SR1: it fails.

I have then uninstalled Winzip 8.1, and have rerun the attempt to download the file and open it directly (Windows XP + Internet Explorer 6). Windows then identifies the file as a compressed folder, and displays an error message saying that the ZIP file is corrupted or invalid.... which it is not...

After having uninstalled Winzip 8.1, I rerun the test having zip compressed the file again using WinRAR 3.71. The problem is the same: Internet Explorer 6 returns a 'compressed folder corrupted' error message when trying to open it directly after having clicked on the download link. So I can rule out the fact that there was an issue with the software used to create ZIP files at our end (Winzip 8.1 or WinRAR 3.71).

One last test I performed, was to FTP the ZIP file at the root of the Drupal install directory, and then try to download it using the direct URL: http:example.com/test.zip (therefore bypassing the Drupal private file system method): the download worke fine.

So to summarize:
* tested on 5 different end-user computers with 3 differents OSes (XP + 2000 + Vista)
* tested on 2 different servers (Windows 2000 + OpenBSD 4.2)
* Zip file created with 2 differents software (Winzip 8.1 or WinRAR 3.71)
* clean URLs turned on or off
* tested with 5 different browsers

=> internet explorer 6 (on XP and Win2000), a still widely used browser, is the only one to have the problem, and it apparently relates to using the Drupal file system (bypassing the drupal file system works OK).

I would be glad if someone could reproduce the issue to confirm it. I have made every effort to ensure that my tests were done correctly (cache + temp internet file folders emptied in between tests, etc) but I may have forgotten something.

CommentFileSizeAuthor
#18 bootstrap.inc_.patch509 bytesshaisachs
#17 cache.patch765 bytesj416
#9 213262-9.patch1.36 KBtraxer
#5 213262-5.patch1.59 KBtraxer
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yuit’s picture

Version: 5.6 » 6.0-rc2
Priority: Normal » Critical

Following-up, I have made a few more tests:

1) switching the file system from 'private' to 'public' solves the problem. So apparently it is an issue only with the private file system.

2) as I had put the content of .htaccess in httpd.conf, I have reverted to using the default .htaccess file as in a default Drupal install. The problem is still there, so the problem is not with the code I had put in httpd.conf apparently.

3) I have now installed a test site using the latest Drupal 6.0-rc2 codebase on the Windows 2000 Server with Apache 2.0.61 ; PHP 5.2.5 ; MySQL 5.0.45 ; configured with private file system ; default .htaccess file ; NO clean URLs.

The problem is still there: on Windows XP, using Internet Explorer 6 and selecting 'Open' after having clicked on the download link, Winzip opens an empty ZIP file with nothing inside. At the same time it works fine with Firefox 2.0.0.11 (I haven't redone the tests with the other combinations of OS/browser).

I am therefore updating this issue to concern Drupal 6.0-rc2, but note that it concerns also Drupal 5.6 on my side.

traxer’s picture

Priority: Critical » Normal

This is a bug in Internet Explorer. Judging from http://support.microsoft.com/kb/308090, the only solution I can think of is, to copy the Zip-File to a location where it can be downloaded without being served by Drupal.

Ugh ... that could be messy.

I changed the priority because over time, fewer users will be affected and only the private method breaks the download.

jbrown’s picture

Priority: Normal » Critical

sounds like upload_file_download() needs to change the http headers it outputs for .zip (probably Content-Type).

You should use wireshark or similar to log the http headers for public and private downloading of a .zip.

jbrown’s picture

Priority: Critical » Normal

sorry - didn't mean to make critical

traxer’s picture

Status: Active » Needs review
FileSize
1.59 KB

Just tested:

Content-Length: 63262
Content-Type: application/x-zip-compressed

Attached patch adds a sentence to the public/private radio buttons:

Due to a bug in Internet Explorer 6 and earlier versions, the Private download of ZIP files does not work reliably with these browsers, see http://support.microsoft.com/kb/308090 for details.
jbrown’s picture

are the headers the same for public and private?

yuit’s picture

The proposed patch is great for alerting administrators when they configure the file system of new sites, but existing sites using the 'private' method with a large number of files are stuck, as switching private => public may not be an option due to the large number of links that may break. And the problem may concern quite a number of users (on one of our sites, 37% of our users still used IE6 for example vs. 32% for IE7 in December).

Just a thought: in case patching to solve the issue is not possible at Drupal's end, what about displaying also a warning message for users at the top or bottom of nodes which include ZIP file attachments when the private method is used ? Such a message could read :

Users of Internet Explorer 6 and earlier versions are invited to see http://support.microsoft.com/kb/308090 if they cannot download ZIP files successfully from this page.

traxer’s picture

If you want to tell your users, there is the option to override theme_upload_attachments. Here is a replacement for the return-statement:

if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
  return theme('table', $header, $rows, array('id' => 'attachments'))
    . '<div class="description">'
    . t('If opening a file directly does not work, save the file to your computer first.')
    . '</div>';      
} else {
  return theme('table', $header, $rows, array('id' => 'attachments'));
}
traxer’s picture

FileSize
1.36 KB

I've nailed the problem down to the Cache-Control header. The patch uses Cache-Control: private instead of Cache-Control: no-cache for private file downloads. Tested on Windows XP with Internet Explorer 6.

The patch does not change the cache-control header if one is supplied by hook_file_download. preg_match is used for PHP4 compatibility.

See also #163298: "Private" download method causes IE (incl. 8.0) to fail downloading attachments.

yuit’s picture

Version: 6.0-rc2 » 6.x-dev

Server: Windows 2000, Drupal 6.0-rc2, php-5.2.5, mysql 5.0.45, Clean URLs, private file system.

Patch tested and working fine with:
Windows XP + Internet Explorer 6
Windows 2000 + Internet Explorer 6

Also tested with:
Windows XP + Firefox 2.0.0.11
Windows XP + Opera 9.25
Windows XP + Safari 3.0.4
Windows Server 2003 + Internet Explorer 7

It works perfectly in all cases as far as I am concerned. Good work, thanks !

hass’s picture

subscribe

cburschka’s picture

I have Internet Explorer 6. What steps do I need to test, pre and post patch, to review this?

yuit’s picture

Any possibility to include the patch in the next maintenance releases of Drupal 6 (6.2) and 5 (5.8) ?

yuit’s picture

(this is in reply to comment #12 above)

You should download and install a website with Drupal 6.1, configure it to use the private download method, or use an existing drupal site already configured to use the private download method (DO NOT switch an existing site from using the public download method to using the private one, or it will break a few things).

Then:
1) create a node which includes as an attachment a ZIP file, then try to click on the download link in IE6 and 'open' the file directly. It should fail (empty ZIP file when opening it with Winzip)

2) merge the patch in #9 above in the file.inc file of the INCLUDES sub-directory of your Drupal site, and re-run the test. It should then work.

traxer’s picture

Rather than working around the bugs in specific browsers, wouldn't it be better to switch from "no-cache" to "private" altogether?

  • Keeps the code cleaner.
  • "must-revalidate" takes care that no old content gets to the browser.

However, I don't know how closely common browsers and proxies follow the HTTP specification (specifically "must-revalidate"). I would be thankful for advice on this subject.

yuit’s picture

Status: Needs review » Closed (won't fix)

As the person who opened this 'issue', I feel I should probably follow up. Many thanks to Traxer for the time spent on the issue and the patch proposed. I am unfortunately not a developer and definitely not skilled enough to provide significant input on the technical side of things.

I am personally losing interest in the issue as we are officially no longer supporting IE6 on our websites, with a banner being added to the pages for people browsing with IE6 strongly encouraging them to upgrade (it is impressive to see in the stats the still large number of people still using IE6 nowadays). So let's clear the queue of pending issues after nearly one and a half year without further input/action on this one. I propose to close it. Anybody with a need for a fix, a strong feeling on the issue and patience to have it reopened, please feel free ;-)

j416’s picture

Status: Closed (won't fix) » Needs review
FileSize
765 bytes

It also fails for PDF files, even with newer versions of Internet Explorer. Suggest patch.

shaisachs’s picture

FileSize
509 bytes

I believe the patch at #17 is for Drupal 7. The attached patch applies the same idea to Drupal 6.

Note that this problem also affects PDF downloads in IE 7 (haven't tried IE 8, but I wouldn't be surprised), so we can't just hope the problem will go away as IE 6 use declines. I imagine IE 7 will be around for a while to come. The patch solves the problem for a Drupal 6 site with private files being downloaded to XP/IE 7.

Anonymous’s picture

I have some clients experiencing the same issue, but only since updating to Drupal 6.16.

In short, when zip files are downloaded using IE 6, 7 and quite possibly 8, they are becoming corrupted (WinRAR reports "unexpected end of archive").

PDF files are working fine.

When downloading zip files with Firefox, they work perfectly and are not corrupted.

I've applied the patch manually by editing the bootstrap.inc file and replacing the line:

header("Cache-Control: store, no-cache, must-revalidate");

with

header("Cache-Control: store, private, must-revalidate");

however, the problem still remains.

Any ideas?

UPDATE:

I've tested this with a completely fresh install of Drupal 6.16, no modules installed except the default modules enabled and the addition of the Upload module.

Once again, I have modified the bootstrap.inc file, however the problem still exists.

I'm testing this using IE7, no proxy, and I flush IE's cache each time.

Once again, Firefox works brilliantly, as does Safari.

Interestingly, the file downloaded through IE is 519,155 bytes while the file downloaded through Firefox is 519,057 bytes in size.

Another uploaded file, a zipped text file (small in size) when downloaded through IE was 1,125 bytes in size, while it was 1,102 bytes in size when downloaded in Firefox.

Strange.

kmillecam’s picture

Subscribing.

Would love to see the priority of this issue raised.

My clients (using private file system) are seeing .zip file corruption with IE6, 7, and 8.

mdlueck’s picture

Subscribe - First I heard of this. However I surf with Firefox.

We have one client that is extensively using Private file attachments. PDF and ZIP files are in the mix. Once the Drupal version of the site goes live, I guess I can expect to hear gripes from those surfing with IE. hhhmmmm....

kmillecam’s picture

I applied the patch in #18 and it didn't help my problem.

The actual message I get when I try do download and uncompress a .zip file is, "The Compressed (zipped) Folder is invalid or corrupted."

If I right-click and "save target as" the download works fine.

Download works fine with Firefox.

Site is http (not https).
Download method is Private.
Target download is in .zip format
Browser is Internet Explorer v8.0.6001.18702

kmillecam’s picture

Title: Opening ZIP files with Internet Explorer 6 fails » Opening ZIP files with Internet Explorer 6 (and IE 8) fails

Changing title to reflect that this issue also impacts users of Internet Explorer 8 (I don't have IE 7 to test against).

Anonymous’s picture

Title: Opening ZIP files with Internet Explorer 6 (and IE 8) fails » Opening ZIP files with Internet Explorer 6, Internet 7 (and IE 8) fails

It's definitely a bug that affects IE 7 as well (Issue title updated to reflect this).

Anonymous’s picture

Title: Opening ZIP files with Internet Explorer 6, Internet 7 (and IE 8) fails » Opening ZIP files with Internet Explorer 6, Internet Explorer 7 (and IE 8) fails
allisonc’s picture

This is happening to me as well. It works fine in Firefox, but when downloading the same exact file in IE 8 it gives me the error message. I'm using Windows 7.

Error: "Cannot open file: it does not appear to be a valid archive. If you downloaded this file, try downloading the file again."
(I click okay)
Errors occurred while extracting. Do you want to view the last output? (I click yes)
"End-of-central-directory signature not found. Either this file is not a Zip file, or it constitutes one disk of a multi-part Zip file."

It happens whether I click open or save.

These are the headers that we have (I didn't write this code so I'm not really sure what all the different items in the header mean) :

//ZipArchive code above

if(ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); }

header('Pragma: public');   
header('Expires: 0');      
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private',false);
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename="'.basename($filename).'"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize($filename)); 
readfile($filename);

Any advice would be helpful..

dbezzant’s picture

We are having the same issue with Drupal 6.17, anyone found a way to really fix this?

micheleannj’s picture

subscribing

kizmar’s picture

Experiencing invalid zip downloads with IE 7 & 8 on Windows 7 with the download method set to public (Drupal 6.19). Is there a fix for this?

kizmar’s picture

Is there a resolution to this issue with IE?

kizmar’s picture

KyleS’s picture

This is not only a Drupal bug. It also affects IIS 7 and at least IE8. Same exact symptoms. User downloads zip file w/ IE and the size is larger than it should be and the zip file won't open. Same exact file downloaded via Chrome or Firefox works fine.

I moved the zip file to an apache server running on Fedora, and it downloaded fine in IE.

Appears to be a bug that affects various versions of IE and some specific web servers. Just thought I would share the extra info as a search for my issue turned up this thread.

Status: Needs review » Needs work

The last submitted patch, bootstrap.inc_.patch, failed testing.

mikinho’s picture

First time experiencing this issue. Glad to see it is fixed in IE9 but for now I did a simple work-around. I added the below to .htaccess

<FilesMatch "\.(?i:zip)$">
  ForceType application/octet-stream
  Header set Content-Disposition attachment
</FilesMatch>
mdlueck’s picture

@mikinho #34

Adding your suggested entries to the .htaccess of Apache 2.2.8 running on Ubuntu 8.04 causes the entire site to get 500 errors. I guess your suggestion also needs a bit of testing.

dgaillour’s picture

Thank you, that fixed the problem for us. We have our site on a shared host and updating the server was really not an option, but the .htaccess is available to us. I expect that the problem will be less of an issue as the general Microsoft OS platform users migrate to Win7 which now includes IE9 by default, but until then, this works.

dfylstra’s picture

On our site with Drupal 6, users download Setup programs which are Windows executables, filename.exe, and these must be (or behave like) private downloads, served from /system/files/... Users with Internet Explorer 8, and some users (based on their reports) with IE 9, were getting this message: "Unable to download filename.exe from www.mysite.com. Unable to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later."

The problem is IE-specific and is documented at http://support.microsoft.com/kb/323308, but in our experience it applies to both https and http downloads, if the server is sending "Cache-control:no-store" or "Cache-control:no-cache". Drupal's bootstrap.inc contains:

header("Cache-Control: store, no-cache, must-revalidate");

We used a hook_file_download function to override this header; for Drupal-served files, it evidently is called early enough (before any headers are sent) so that PHP will replace the bootstrap.inc header with the newly supplied header. So we use just this:

function mymodule_file_download($filepath) {
header("Cache-Control: private, must-revalidate");
}

IE is still basically a black box, but we're reasonably confident about this fix: We could reproduce the user-reported download problem with IE8 on a VM. When we made the Registry changes affecting IE on the client side as described at http://support.microsoft.com/kb/323308, the download problem was resolved -- but of course our users cannot be expected to do this. When we added the hook_file_download function above (and didn't make the Registry changes), the problem was also resolved. We have up to 1,000 downloads per day so if the problem was still occurring I'm pretty sure we would hear about it.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.