Subject: | Problem with multibyte characters and file attachments for uploads |
Perl version 5.6.1 using libwww-perl-5.802 (older libwww's showed this problem as well).
Unfortunately can't produce full test code right now but will if necessary (the failure case relies on an externally received multibyte string) (really sorry).
To reproduce:
- Retrieve/create a multibyte string
- Do a multipart/form-data post which includes the multibyte string as a parameter and a file upload (snippet below).
- When uploaded, the multipart headers will be correct but the actual data transferred will be corrupted.
- Forcing the string parameter to 7-bit fixes the problem: use Unicode::String qw(utf8); $mb = utf8($mb)->utf7;
my $ua = LWP::UserAgent->new;
my $req = POST("$url",
Content_Type => 'multipart/form-data',
Content => [
'upload' => [$file,$name,'Content_Type'=>'image/jpeg'],
'mb' => "$mb",
],
);
Other information:
The code was executed by the same script using SOAP::Lite which had the keepalive patch applied -- this may have affected things. The value passed as a parameter ($mb in the above snippet) came directly from a SOAP::SOM->ValueOf("//...") call.
Again - sorry about the lack of a working test case.