Subject: | Message affected by 'use utf8', breaks binary POSTs |
It appeared to us that POSTing binary data with LWP corrupted the data
when (and only when) we had ‘use utf8’ enabled in the script using LWP.
This bug was present in LWP 5.833 as well as the newest HTTP::Message 6.03.
‘use utf8’ doesn't do anything but turn the strings in the source code
into string of characters, rather than octets -- it seems that
HTTP::Request::Common is completely encoding (and u-string) agnostic,
which is VERY dangerous in a place where you manipulate octet streams.
The source of the problem is that you have strings in the source code
(eg. where you add the Content-Disposition header[1]), and *also* read
bytes from the file into the same buffer later on[2]. One is easily a
character string, the other is definitely an octet stream.
Not sure what the right solution is, but the module should safeguard
itself against these kinds of things.
[1]
https://metacpan.org/source/GAAS/HTTP-Message-6.03/lib/HTTP/Request/Common.pm#L135
[2]
https://metacpan.org/source/GAAS/HTTP-Message-6.03/lib/HTTP/Request/Common.pm#L243
P.S. Might be a similar issue, we also recently noticed that https and
use utf8 breaks a HTTP request, either or both of them missing doesn't.
PPS. Perl 5.10.1, Linux 3.1 x86.