Subject: | utf-8 request data not properly encoded |
Despite what seems like a valiant attempt at properly encoding UTF-8 (by
creating an XML::Writer with the ENCODING set to UTF-8), utf-8 data is
not sent properly on the wire.
This is because:
1) XML::Writer ignores the UTF-8 encoding when the destination (OUTPUT)
is a scalar variable
2) HTTP::Request expects a pre-encoded (i.e. byte semantics) scalar and
it actually "downgrades" any utf-8 strings to native encoding.
Perhaps if #1 was working, #2 wouldn't be an issue, but c'est la vie.
The attached patch does an explicit encode of the utf-8 data, and also
changes the content-type to indicate the encoding on the wire.
Subject: | BZ-Client-utf8-encoded-request.patch |
--- BZ/Client/XMLRPC.pm~ 2012-07-31 09:01:16.768512148 -0400
+++ BZ/Client/XMLRPC.pm 2012-07-31 09:01:12.074537090 -0400
@@ -10,6 +10,7 @@
use LWP();
use XML::Writer();
use BZ::Client::XMLRPC::Parser();
+use Encode;
our $VERSION = 1.0;
our $counter;
@@ -127,8 +128,8 @@
sub get_response($$) {
my($self, $contents) = @_;
return _get_response($self, { "url" => $self->url() . "/xmlrpc.cgi",
- "contentType" => "text/xml",
- "contents" => $contents });
+ "contentType" => "text/xml;charset=utf-8",
+ "contents" => encode_utf8($contents) });
}
sub _get_response($$) {