Ticket #3225 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Export file does not download in FF

Reported by: Viper007Bond Assigned to: markjaquith
Priority: normal Milestone: 2.1
Component: Administration Version: 2.1
Severity: normal Keywords: export has-patch needs-testing
Cc:

Description

Latest SVN as of the time of this post. Clicking on "Download Export File" on the export page takes me to the XML file. It doesn't offer it up for download. FF2.0RC2, haven't tried in IE or anything else.

Attachments

3225.diff (1.5 kB) - added by mdawaffe on 11/08/06 08:51:00.
3225b.diff (2.1 kB) - added by mdawaffe on 12/01/06 00:05:47.

Change History

10/09/06 03:31:46 changed by markjaquith

  • owner changed from anonymous to markjaquith.
  • status changed from new to assigned.

Unfortunately, FF2.0RC2 is sniffing the content of the file, and serving it up to your designated feed reader (or apparently, viewing in-browser if no feed reader is designated), totally IGNORING the Content-Disposition header. Even sending it as text/plain doesn't work (although it fools Safari, which appears to also ignore Content-Disposition for things sent with text/xml).

See: http://weblogs.mozillazine.org/ben/archives/010116.html

One way to get around it might be to compress the XML into a gzip (or zip) file before offering it for download. That'd speed up the download, but I don't know how much longer the server would have to chew on it, and people with 8MB for PHP might be in trouble... I know that PHPMySQL's compression option has bitten me before, leaving me with corrupted gzip files.

Hopefully this behavior will be fixed by 2.0 release.

Here's the Firefox bug ticket (opened a few days ago):

https://bugzilla.mozilla.org/show_bug.cgi?id=355332

We still have to deal with Safari, however.

10/10/06 19:40:58 changed by philor

Missed the Fx 2.0 boat, but it should wind up in 2.0.0.1.

If that's bad timing for a WP release, you can work around it with a 512 byte comment (<!-- Content sniffing is evil. Really evil. Really, really evil. ... -->) between the XML decl and the root element. No idea if that will keep Safari's nose out of your non-feed, though.

10/22/06 03:27:17 changed by markjaquith

This all comes down to the timing for FF 2.0.0.1 If we're ready to release WP 2.1 and FF 2.0.0.1 isn't out with a fix, we should probably take Phil's advice regarding the 512 byte comment. If FF is fixed after, we can take it out in a 2.1.1 release.

Safari is a different matter. I don't think Safari is sniffing the content. Sending as text/plain fools Safari.

How important is it to send text/xml like we're doing now? It's supposed to be a download, so as long as it gets handled as text, what's the harm in sending it as text/plain?

10/29/06 17:52:18 changed by Viper007Bond

I dunno how vBulletin does it, but I can click a button to download my theme as a XML file and it pops up a download box as it should.

You guys are doing something wrong. :P

10/29/06 18:02:37 changed by Viper007Bond

Okay, I found it in vB's source and here's what it sends:

header('Content-Type: ' . $filetype);
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Disposition: attachment; ' . $filename);
header('Content-Length: ' . strlen($filestring));
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');

echo $filestring;
exit;

I'd paste the whole file_download() function and the tweaks it does to $filename, but the vB license doesn't allow me to redistribute it's code and I don't want to risk it anymore than I have just done now. ;)

10/30/06 18:00:27 changed by foolswisdom

Viper007Bond you do not tell us what version of Firefox you are experiencing the problem with? If Firefox 2, it should be resolved in the 1st maint release of Firefox 2.

I imagine vBulletin is not doing anything more correctly, they just get lucky with this bug.

11/01/06 23:42:21 changed by Viper007Bond

Latest stable of course (2.0). ;)

11/08/06 08:51:00 changed by mdawaffe

  • attachment 3225.diff added.

11/08/06 08:57:24 changed by mdawaffe

3225.diff

  1. Pads export file with helpful comments to fix FireFox 2 issue.
  2. Sends ~made-up Content-type: text/wxr+xml to fix Safari Issue.

Works in

  1. FF 2
  2. FF 1.5.0.7
  3. Safari 2.0.4
  4. Opera 9.02
  5. IE 7

Not tested in IE 6

11/08/06 09:24:54 changed by mdawaffe

  • keywords set to has-patch 2nd-opinion.

11/17/06 23:13:15 changed by foolswisdom

  • keywords changed from has-patch 2nd-opinion to has-patch.

Has been deployed on wordpress.com for about a week and no issues identified. Removing '2nd-opinion' keyword though opinions always welcome.

11/18/06 01:27:23 changed by ryan

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [4477]) Force download of export file in browsers that try to be too smart. Props mdawaffe. fixes #3225

11/19/06 00:08:26 changed by random

  • keywords changed from has-patch to 2nd-opinion export.
  • status changed from closed to reopened.
  • resolution deleted.

As posted at wp-hackers, I don't think text/wxr+xml is a good choice of media type. I'd recommend something like application/prs.wordpress.export+xml. (Or application/vnd.automattic.wxr+xml, or whatever. There are plenty of options.)

For background, check out RFC4288 and the IANA media type registry.

11/30/06 00:07:21 changed by matt

  • status changed from reopened to closed.
  • resolution set to fixed.

12/01/06 00:05:28 changed by mdawaffe

  • status changed from closed to reopened.
  • resolution deleted.

Still broken in IE7

Still broken on IE7.

Fix: use text/xml (which will make people happy :) ). I've searched far and wide and this is the only way to get things working in IE7.

That breaks Safari unless we pad the file with an even more verbose message.

Attached tested on IE7, IE6 (may not respect content-disposition filename), FF2, Safari latest, Opera latest.

12/01/06 00:05:47 changed by mdawaffe

  • attachment 3225b.diff added.

12/01/06 00:06:19 changed by mdawaffe

  • keywords changed from 2nd-opinion export to export has-patch needs-testing.

12/01/06 00:14:29 changed by ryan

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [4563]) Export file content type fixups from mdawaffe. fixes #3225