bug-wget
[Top][All Lists]
Advanced

[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

Hello,
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:
http://www.vladpride.cz/res/content-disposition-with-unicode.php

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

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

You can use the following command to test it:

wget --content-disposition --restrict-file-names=nocontrol "
http://www.vladpride.cz/res/content-disposition-with-unicode.php";

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
as:

a%C3%A1c%C4%8D%20d%C4%8Fs%C5%A1%20z%C5%BEr%C5%99%20i%C3%ADn%C5%88.txt

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.

Cheers,
Vlad

Attachment: content-disposition.patch
Description: Text Data


reply via email to

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