Edgewall Software
Modify

Opened 17 years ago

Closed 17 years ago

#6798 closed enhancement (fixed)

Internet Explorer 6/7 shows "Unknown File Type"

Reported by: Ross Owned by: Christian Boos
Priority: normal Milestone: 0.11
Component: version control/browser Version: 0.11b1
Severity: minor Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Dear Trac Developers,

Sorry for posting it like a ticket for Trac, though its actually a ticket for installation problem with my configuration:

Internet Explorer 6/7 shows "Unknown File Type" when you click on links like "Unified Diff" and "Zip Archive" in Browser or Changeset and loads a file without extension. So you have to add .zip or .diff file extension manually. Firefox and Opera work ok.

I guess the problem is with my Apache 2.2 installation. Checked httpd.conf - mime types are set correctly, application\zip → .zip and so on.

Could you point what may be wrong?

Attachments (2)

explict_extension_for_changesets-r6501.diff (2.7 KB ) - added by Christian Boos 17 years ago.
Workaround an IExplorer limitation - it's only when .diff or .zip is in the URL that IE will propose to do the appropriate action on the downloaded file
explict_extension_for_changesets-r6502.diff (3.4 KB ) - added by Christian Boos 17 years ago.
Force IExplorer to do the right thing with alternate downloads in changeset module

Download all attachments as: .zip

Change History (22)

comment:1 by Christian Boos, 17 years ago

Milestone: 0.110.12
Severity: normalminor

Right, that's an annoying problem with IE, I don't think it's a misconfiguration on your part (anyway, it should work out of the box).

I think adding an explicit .diff and .zip extension where needed is doable.

comment:2 by osimons, 17 years ago

I think this is closely related to #5557 - bordering on duplicate?

comment:3 by Christian Boos, 17 years ago

Milestone: 0.120.11.1

No, not really.

Looking at the code, it seems we already use filename for diffs and zips.

  req.send_header('Content-Disposition',
                  content_disposition('inline;', filename + '.diff'))

But IExplorer happily discards the info. Using 'attachment' disposition doesn't fix it. I think the only change that could possibly convince IExplorer to do right thing would be to redirect to /changeset/xxxx.diff or /changeset/xxxx.zip.

See attachment:explict_extension_for_changesets-r6501.diff. With that change, both the diff files and the zip files are opened appropriately when using IE (FF and Opera are still doing fine).

(Now speaking of #5557, feel free to re-schedule it, as you saw some improvement by using the patch you proposed there - but AFAICT that ticket was more about the extension for attached files dissapearing, whereas here there were no such extensions before the patch added them).

by Christian Boos, 17 years ago

Workaround an IExplorer limitation - it's only when .diff or .zip is in the URL that IE will propose to do the appropriate action on the downloaded file

comment:4 by osimons, 17 years ago

Tested attachment:explict_extension_for_changesets-r6501.diff, and that sure seems to work better. +1 on such a workaround as it is quite an annoying issue.

Only remaining thing I can see is that the naming of the file is wrong. Instead of the FF behaviour of changeset_r125.diff naming, the filename looks to be a temporary filename - actually, just clicking the link and then 'Cancel' suggests a new name each time.

comment:5 by osimons, 17 years ago

Tested using downloadable paths as well, and that shows same behavior: Not solved by patch, so I suppose there is another location in the code that needs the treatment.

Typically downloading /trunk as .zip, will just request to save trunk in IE.

comment:6 by Christian Boos, 17 years ago

Milestone: 0.11.10.11
Status: newassigned

Please have a look at the newer patch (attachment:explict_extension_for_changesets-r6502.diff), which should take care of the downloadable paths as well.

by Christian Boos, 17 years ago

Force IExplorer to do the right thing with alternate downloads in changeset module

in reply to:  6 comment:7 by osimons, 17 years ago

Replying to cboos:

Please have a look at the newer patch (attachment:explict_extension_for_changesets-r6502.diff), which should take care of the downloadable paths as well.

Yup. The dialogue and download is working well. Correct file types.

As for using 'file.zip' or 'file.diff' for all such IE downloads, I suppose it is as good as it gets. Making it more explicit can lead to confusion as the patch don't actually use the filename as a relevant part of the path - only stripping it off. It makes for nicer links, but more hassle at the receiving IE end when all files still needs to be renamed to be descriptive.

comment:8 by Christian Boos, 17 years ago

Apparently, the only way to avoid the need for renaming would be to prepare the full name in the link (doable), and set what has to be stripped as an extra parameter.

e.g.

/changeset/changeset_r321.diff?format=diff&rev=321&strip=changeset_r321.diff

I'm not sure. The link sure looks ugly but it's not really meant to be seen nor used directly. The benefits seem to outweight the disadvantages though.

comment:9 by anonymous, 17 years ago

Thanks, I wil test the patches. For some unknown reason for me on your site

http://trac.edgewall.org/browser/trunk

the "Download Zip" links worked correct with IE even before I created the ticket. Did you already use some top-secret patches and made them public only now? :)

comment:10 by anonymous, 17 years ago

I tested r6502.diff and it is working as you explained above.

Only problem is that name of file in IE is always "file.zip", not path-rXXX.zip.

But could anyone explain me WHY here http://trac.edgewall.org/browser/trunk everything is working fantastic with IE (and the filename is correct). Is this some new version of Apache or some new fix mwe are not aware of?

comment:11 by Jeroen Ruigrok van der Werven, 17 years ago

t.e.o. still uses 0.10.4. It would be interesting to see if a 0.10.4 does it correctly.

comment:12 by osimons, 17 years ago

It is related to #5557 and the change on trunk in [4351] not present for 0.10-stable.

Here is a diff that I think solves it:

  • trac/util/__init__.py

     
    468468
    469469def content_disposition(type, filename=None):
    470470    """Generate a properly escaped Content-Disposition header"""
    471     from email.Utils import encode_rfc2231
    472471    if isinstance(filename, unicode):
    473472        filename = filename.encode('utf-8')
    474     return type +'; filename*=' + encode_rfc2231(filename, 'utf-8')
     473    return type + '; filename=' + quote(filename, safe='')
    475474
    476475def pairwise(iterable):
    477476    "s -> (s0,s1), (s1,s2), (s2, s3), ..."

encode_rfc2231('trunk.zip', 'utf-8') returns a funny-looking string like "utf-8''trunk.zip". No browser handles this string in any meaningful manner. This has never really been noticeable due to what surely must be a spelling mistake - filename*= instead of filename=. Quoting without safe characters returns the same result for international characters, so the patch just uses that.

Related again to #5557, what happens now:

  • Correct 'save as…' display for all regular ascii filenames on all major platforms.
  • Any international characters in filename will be quoted:
    • IE will actually unquote it automatically when 'utf-8' so that looks great.
    • Mozilla does not unquote, and will save a quoted filename.

Patch makes it perfect for IE, and worse for Mozilla and Safari now that the header actually gets recognized overriding their built-in auto-detection of the filename. Without browser detection in code, I don't think there is any ideal way to do this - basically do conditional include of the filename= attribute if we don't consider quoting an OK solution.

comment:13 by anonymous, 17 years ago

The original bug description says "Checked httpd.conf - mime types are set correctly, application\zip → .zip and so on."

Note that the separator "application\zip" is a backslash. Is that a typo? It should be a forward slash "application/zip"

References:

in reply to:  13 comment:14 by osimons, 17 years ago

Replying to anonymous:

The original bug description says "Checked httpd.conf - mime types are set correctly, application\zip → .zip and so on." Note that the separator "application\zip" is a backslash. Is that a typo? It should be a forward slash "application/zip"

Nope. The problem is not with the web server setup. The problem is confirmed by many and researched by several devs, and we do have a problem of finding the best way to present and handle downloads so that all browsers treat them in a user-friendly manner.

comment:15 by anonymous, 17 years ago

Resolution: fixed
Status: assignedclosed

comment:16 by anonymous, 17 years ago

Resolution: fixed
Status: closedreopened

comment:17 by anonymous, 17 years ago

Guys you need to look into security? I was able to close this issue without having to login to the system…

I'm not sure it's right behavior of the system

Regards, Alexey

in reply to:  17 comment:18 by osimons, 17 years ago

Status: reopenednew

Replying to anonymous:

Guys you need to look into security? I was able to close this issue without having to login to the system…

I'm not sure it's right behavior of the system

Well, it is correct behaviour. And, no doubt you could have figured that out by looking around instead.

This site contains contributions and involvement from a large number of people, and only a fraction of them (developers) have logins. With the exceptions of spam, test tickets and test edits, and people proving points (like you), this open policy is a very positive aspect of the project. All changes are tracked by a large number of people helping out, and wrong or malicious changes would not stay that way for long. However, we would all rather spend our time doing other things than undoing stupid changes.

Regards, Alexey

Alexey, you are empowered. Please use it for contributions that actually bring value to others.

in reply to:  12 comment:19 by Christian Boos, 17 years ago

Replying to osimons:

It is related to #5557 and the change on trunk in [4351] not present for 0.10-stable.

Here is a diff that I think solves it:

I tried that patch.

  • Any international characters in filename will be quoted:
    • IE will actually unquote it automatically when 'utf-8' so that looks great.
    • Mozilla does not unquote, and will save a quoted filename.

I don't know if you were talking about "Mozilla" or Firefox, but for me, FF 2.0.0.14 on Windows does the right thing.

That was with tracd on the server side, so no httpd.conf - mime types involved here.

I also tested with Safari 3.1.1, Opera 9.27 and IE 7, all are working fine with the changesets diffs and .zip files.

Patch makes it perfect for IE, and worse for Mozilla and Safari now that the header actually gets recognized overriding their built-in auto-detection of the filename. Without browser detection in code, I don't think there is any ideal way to do this - basically do conditional include of the filename= attribute if we don't consider quoting an OK solution.

I also checked that downloading attachments or files from the repository (with non-ascii characters) is still working as expected using all of the above browsers, so there seems to be no regression on #5557.

I think this looks good for rc1.

comment:20 by Christian Boos, 17 years ago

Resolution: fixed
Status: newclosed

Fix from osimons in comment:12 committed as r6935.

I also tried on Linux with an old Konqueror browser (3.2.1). With this browser, the diff and zip download were also not working, but the above fix did the trick for that browser as well.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.