Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-11-18 03:16:12

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,595
Website

unencoded ampersand in download link, r2089

@ rev 2089 (could be a bit older, haven’t updated for a few days).

<txp:file_download_link>download: <txp:file_download_name /></txp:file_download_link>

results in the following html

<a href="http://127.0.0.1/file_download/6/phiw_DTD-plugin.tgz&">

An ampersand is added to the download link (file name).

  • invalid html (the ampersand is not encoded).
  • download fails: file not found
  • malformed xml for those 3 users who actually use xhtml as it should: application/xhtml+xml – ugly yellow page in Gecko browsers.

———-
[update]: it seems to happen only with .tgz files.

Last edited by phiw13 (2006-11-18 03:31:50)


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

#2 2006-11-18 05:15:54

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: unencoded ampersand in download link, r2089

Hmm… Thanks for reporting this, I’ll try and figure out what’s going on.

Offline

#3 2006-11-18 21:31:18

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: unencoded ampersand in download link, r2089

The ampersand is supposed to be there, though it should be encoded. It fixes a browser issue on servers that use mod_gzip or mod_deflate.

I don’t think the 404 is related to the ampersand.


Alex

Offline

#4 2006-11-18 22:26:42

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: unencoded ampersand in download link, r2089

Why not set $filename to ‘’ (empty string) if the extension is .gz or .tgz? If you’re not using the real filename, might as well leave it out completely.

Hmm… perhaps stripping .gz (or replacing .tgz with .tar) would work, if combined with a header “Content-Encoding: gzip”. Of course this should only be done if the client sends an Accept-Encoding header that includes ‘gzip’.

Last edited by ruud (2006-11-18 22:34:18)

Offline

#5 2006-11-19 01:13:38

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,595
Website

Re: unencoded ampersand in download link, r2089

zem wrote:

The ampersand is supposed to be there, though it should be encoded. It fixes a browser issue on servers that use mod_gzip or mod_deflate.

Ah, ok, thanks for explaining the why. Scrolling back through the Trac feed, I see that you did a checkin for that mod_gzip or mod_deflate problem. Missed that one.
Thing (the ampersand) should be encoded, though.

I don’t think the 404 is related to the ampersand.

My bad. I only tested with Gecko and Safari, both get application/xhtml+xml (and thus xml errors. I had copy pasted from source code the link in the locationbar, but it gave a 404. I now checked with iCab (gets html 401, text/html, no error) and the file did download (of course).

For downloads, wouldn’t it make sense to set the content-type to application/octet-stream ?

Last edited by phiw13 (2006-11-19 01:14:35)


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

#6 2006-11-20 04:51:06

akokskis
Plugin Author
From: Baltimore-ish, USofA
Registered: 2004-11-28
Posts: 230
Website

Re: unencoded ampersand in download link, r2089

phiw13 wrote:

For downloads, wouldn’t it make sense to set the content-type to application/octet-stream ?

IIRC, this only works with certain browsers, and fails in others cough ie cough

I could be wrong though.


My Photoblog, and my personal site. Got nav? ako_nav.
Thanks for taking the time to look…

— vc3 —

Offline

#7 2006-11-20 21:37:42

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: unencoded ampersand in download link, r2089

There’s more about the problem here. Textpattern does use octet-stream; we’re doing the right thing, it’s other software (mod_deflate and browsers) that are screwing it up.

Last edited by zem (2006-11-20 21:38:37)


Alex

Offline

#8 2006-11-20 23:17:42

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,595
Website

Re: unencoded ampersand in download link, r2089

@ zem,
Thanks for rev 2093. Problem is fixed now !
:-)


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

#9 2006-11-20 23:31:52

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: unencoded ampersand in download link, r2089

Since the & is not a query string separator here, shouldn’t it be urlencoded instead of html encoded?

Offline

#10 2006-11-21 00:18:14

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: unencoded ampersand in download link, r2089

It’s intended to be interpreted as a qs separator. The browsers I’ve tested strip it out when saving the file.


Alex

Offline

#11 2006-11-21 08:46:12

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: unencoded ampersand in download link, r2089

interesting… I though an unencoded & was not allowed in an URL except as part of the the query string (there’s no ?, so it’s not a qs separator here), but to my surprise it is a valid character in the url-path, so in this case it should be considerered as part of the url-path.

Am I correct in thinking that the browser doesn’t strip off the &, but uses the filename as set in the Content-Disposition header, which doesn’t have the trailing &?
And if that’s so, would it make sense to just strip the .gz part of the filename when used in the URL (not in the Content-Disposition header), so it looks to the user like he’s downloading a tar file instead of a tar.gz& file? While both don’t match the actual filename, the first looks less hackish.
It’s also easier for people using wget from the commandline, because the & has special meaning there (of course, one should put the URL in quotes, but people (at least I) tend to forget that).

Offline

Board footer

Powered by FluxBB