views:

236

answers:

3

I've made an application that takes tagged versions of a project from an hg repository and creates a downloadable ZIP file of that the tagged revision.

The files are created on a MediaTemple server running Linux using CodeIgniter's ZIP Encoding Library. Everything works fine... on a Mac. But, when I download the files on a Windows computer, the archive is blocked from being extracted.

The ZIP contains .html, .css, .gif, .png and .js files, and I am pretty sure the .js files are the security culprit, but I am wondering why I can download the Jcrop jQuery plugin (or any other examples) as a ZIP file and extract it without Windows ever interfering, even though it obviously contains .js files, but something about my ZIP file is posing a security risk.

Normally I would just find a quick software workaround for my particular situation, but since the plan is to sell access to these files, a quick software fix or an FAQ doesn't seem very user-friendly.

Any feedback would be greatly appreciated! Let me know if you need more info.

You can download an example file here.

EDIT:

  • I am running Windows XP
  • I am not running anti-virus
  • The warning is: Windows has blocked access to these files to help protect your computer
  • I've unblocked the file but that does nothing
  • The file is on my desktop

EDIT 2:

  • I added an example file at the bottom. Or you can see it here
  • I have only used default extraction tools on XP and Windows 7.
  • The ZIP appears to be empty on Windows and I can't see or open any of the files.

EDIT 3:

  • From the comments and answers, it appears that the file names were the problem due to an extra / being added somewhere in the process. I've uploaded an new example download generated by my app with the file name fix, which you can download here. Please let me know if that fixes the problem.
A: 

It might help to mention which version of windows you are using as well as the exact error you're getting. Is it windows 7 and you're trying to open files in a protected folder by chance or are you just trying to open it on the desktop?

I don't think this has anything to do with the the way the zip file was made but I could be wrong.

stoj
I updated my question... XP... on the desktop.
bschaeffer
+3  A: 

This can happen when files are zipped using the full directory path rather than the relative path. You can find an example of this problem here:

http://community.sharpdevelop.net/forums/p/1416/4532.aspx#4532

You may have to use another zip utility or write your own.

tamewhale
I thought this might be the case. This is actually one of those things were it worked the first time, but the project was getting out of hand so I scrapped a lot of code. When I went back and looked I noticed that the way I was referencing the files was different the first time. I'll have to test it on Monday when I get ahold of a PC.
bschaeffer
+4  A: 

Indeed, the leading '/' is what's causing the zip to not be allowed to be extracted. I've proven this by writing a Python script to create a modified version of the zip file without the absolute file paths:

from zipfile import *

orig = ZipFile('download.zip', 'r')
fixed = ZipFile('fixed.zip', 'w')
for fileinfo in orig.infolist():
    fixed.writestr(fileinfo.filename[1:], orig.read(fileinfo.filename)) 
fixed.close()

(this doesn't re-compress the files, but it proves it's the file names that are causing the problem)

If you're using the CodeIgniter zip library's function read_dir, then that must be the culprit that's using absolute file paths. Try recursively walking the directory structure using PHP instead and use the add_data function instead. That allows you to use any arbitrary path structure for each file, so you can write relative paths.

Jacob
I added a fixed example download... would you let me know if that fixes the problem. It should be easily extractable by a regular old user. I would, but I don't have access to a PC on the weekends :)
bschaeffer
Yep. That works on my machine.
Martin Smith