Edgewall Software
Modify

Opened 18 years ago

Closed 17 years ago

Last modified 17 years ago

#3083 closed defect (fixed)

Bad handling of URLs in IE5/6 when downloading files in raw format

Reported by: Christophe.Muller@… Owned by: Christian Boos
Priority: normal Milestone: 0.11
Component: version control/browser Version: 0.9.3
Severity: normal Keywords: IE, raw, HTTP
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Hello,

The problem really lies in Internet Explorer I think and not trac but the fact that the URL for original format links would be of the form "…/file.exe?format=raw" (or any other binary type) makes IE want to save a file called "file" without the extension, and thus… that cannot be ran afterwards. It also happens for example when the URL is "…/file.tgz?format=raw" in which case IE renames it to "file.tar"!???! I have tried to look for solutions on the web but could only find people with the same problem. One of the suggestions, though, was to add to the HTTP header a Content-Disposition field which forces 1) a download and 2) a filename (this HTTP feature is described in RFC 1806).

I have patched my own working copy of trac with the following code (file versioncontrol/web_ui/browser.py) in _render_file:

format = req.args.get('format')
if format in ['raw', 'txt']:
    req.send_response(200)
    if format == 'raw':
        filename=node.path.split('/').pop()
        req.send_header('Content-Disposition', 'attachment;' + 'filename=' + filename)
    req.send_header('Content-Type',
                    format == 'txt' and 'text/plain' or mime_type)
    req.send_header('Content-Length', node.content_length)
...

And it seems to do the trick for IE: when clicking on raw versions, IE now proposes to save the file with exactly the file name that we send in the HTTP header.

I'm not sure you will want to fix IE bugs with workarounds :-) but just in case, I fill this ticket. Thanks for the attention.

Cheers,

Christophe.

= Ubuntu is an ancient African word, meaning "I can't configure Slackware". =

Attachments (2)

trac-raw-handling.patch (630 bytes ) - added by Christophe.Muller@… 18 years ago.
Patch. It seems my bug is still new five month later… :-(
raw-source-r4039.diff (2.0 KB ) - added by Christian Boos 18 years ago.
Add direct raw access to files in the repository

Download all attachments as: .zip

Change History (9)

comment:1 by schuetze@…, 18 years ago

The same problem exists for attachments in the wiki (see attachment.py). There is a HTTP-header 'Content-Disposition', but only for not-binary - why? Binaries should have this header also.

by Christophe.Muller@…, 18 years ago

Attachment: trac-raw-handling.patch added

Patch. It seems my bug is still new five month later… :-(

comment:2 by Christian Boos, 18 years ago

Milestone: 0.10.1
Owner: changed from Jonas Borgström to Christian Boos
Status: newassigned

Sorry, the patch/issue probably got unnoticed.

Also, #3332 supersedes this one, for 0.11dev.

We could probably put that in 0.10.1, though. Any objections?

in reply to:  2 comment:3 by Christophe.Muller@…, 18 years ago

Replying to cboos:

Sorry, the patch/issue probably got unnoticed.

No problem. I understand that can happen (and I have my patch installed already.. :-).

Thanks for picking it up.
Cheers,
Christophe

 = The game's isn't over until it's over.  --Yogi Berra =

comment:4 by Christian Boos, 18 years ago

Priority: lownormal

Oops, just tested this further, and the proposed patch actually enforces a download of the page, which prevents the document to be viewed directly in the browser, which is often desirable for e.g. viewing HTML documentation stored in the repository.

So the correct solution for this issue seems to be to get rid of the ?format=raw. This can be achieved using the patch I proposed a few time ago on the ML, which proposed a /source/ access besides /browser/ (and also a raw-source: TracLinks resolver for this; admittedly source: would be better, but it's already widely used as an alias to browser:).

See attachment:raw-source-r4039.diff

by Christian Boos, 18 years ago

Attachment: raw-source-r4039.diff added

Add direct raw access to files in the repository

comment:5 by Christian Boos, 17 years ago

Also, as noted in #3579, the first "path" element should be mandatory and interpreted as a revision number.

Instead of /source for the URL and raw-source: for the link resolver, the idea is now to use /export and export:.

The question is open whether we'd support something similar for attachments (e.g. /raw-attachment/wiki/page/document.pdf, revival of #2974 only for attachments).

in reply to:  5 comment:6 by Christian Boos, 17 years ago

Milestone: 0.10.20.11
Resolution: fixed
Status: assignedclosed

Implemented in r4242.

The Original Format alternate download link now use this new export URL.

comment:7 by Christian Boos, 17 years ago

In r4246, the same approach was used for the attachments (raw-attachment: link resolver in the Wiki and /raw-attachment URL prefix).

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.