Skip Menu |
 

This queue is for tickets about the BZ-Client CPAN distribution.

Report information
The Basics
Id: 78694
Status: resolved
Priority: 0/
Queue: BZ-Client

People
Owner: Nobody in particular
Requestors: bitcard [...] dm.cobite.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.04
Fixed in: (no value)

Attachments


Subject: utf-8 request data not properly encoded
Download (untitled) / with headers
text/plain 630b
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($$) {
Download (untitled) / with headers
text/plain 793b
On Tue Jul 31 12:08:54 2012, dmansfield wrote: Show quoted text
> 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. >
i have added this patch to my github copy -> https://github.com/djzort/BZ-Client
released


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.