[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-wget] Submitting a patch fixing the --content-disposition option of

From: Vladimír Pýcha
Subject: [Bug-wget] Submitting a patch fixing the --content-disposition option of wget
Date: Wed, 12 Feb 2014 09:48:30 +0100

I have created a small patch for wget 1.15. It is related to the
experimental --content-disposition option. The patch is attached.

This patch ensures that if the filename parameter of Content-Disposition
header is url-encoded as described in RFC 2231, then wget decodes it (the
character set is ignored).

Besides using the --content-disposition option, there may be also needed to
use the --restrict-file-names=nocontrol option to avoid wget from escaping
some characters of the filename.

I have created a testing URL:

The source code of the PHP script at that URL is as follows:

$str = 'aácč dďsš zžrř iínň';
header('Content-Type: text/plain; charset=UTF-8');
header("Content-Disposition: attachment;
echo $str;

You can use the following command to test it:

wget --content-disposition --restrict-file-names=nocontrol "

Using the above command, my patched version of wget correctly saves the
file as:

aácč dďsš zžrř iínň.txt

Using the same command with unpatched wget, the file is incorrectly saved


It would be great if my patch could be incorporated into the next release
of wget.

I have created the patch file with the following command:

diff -rupN wget-1.15/src/ wget-1.15-custom/src/ > content-disposition.patch

You can apply the patch with the following command, while in the directory
where the source code tarball was extracted to:

patch -p1 < ../content-disposition.patch

Then the output will be like this:

patching file src/http.c
patching file src/http.h
patching file src/url.c
patching file src/url.h

Note that in my system, Ubuntu 12.04, I had to install package
libgnutls-dev to be able to compile wget.


Attachment: content-disposition.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]