summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2011-02-14 21:03:48 +0100
committerMax Kanat-Alexander <mkanat@bugzilla.org>2011-02-14 21:03:48 +0100
commitf843497fb2836d42712a6bd66e08c3bd9f49dc2c (patch)
treeaa1ab2d02a5d9088c7e8f8a423a1317cc2e41126 /Bugzilla
parenta4ae80a43078cb33f759863c6f436619290137c3 (diff)
downloadbugzilla-f843497fb2836d42712a6bd66e08c3bd9f49dc2c.tar.gz
bugzilla-f843497fb2836d42712a6bd66e08c3bd9f49dc2c.tar.xz
Bug 609538: Make the JSON-RPC interface support UTF-8 when a recent version
of LWP is installed r=dkl, a=mkanat
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/WebService/Server/JSONRPC.pm17
1 files changed, 16 insertions, 1 deletions
diff --git a/Bugzilla/WebService/Server/JSONRPC.pm b/Bugzilla/WebService/Server/JSONRPC.pm
index 49520505a..8fe724080 100644
--- a/Bugzilla/WebService/Server/JSONRPC.pm
+++ b/Bugzilla/WebService/Server/JSONRPC.pm
@@ -27,8 +27,9 @@ use base qw(JSON::RPC::Server::CGI Bugzilla::WebService::Server);
use Bugzilla::Error;
use Bugzilla::WebService::Constants;
use Bugzilla::WebService::Util qw(taint_data);
-use Bugzilla::Util qw(correct_urlbase trim);
+use Bugzilla::Util qw(correct_urlbase trim disable_utf8);
+use HTTP::Message;
use MIME::Base64 qw(decode_base64 encode_base64);
#####################################
@@ -59,6 +60,20 @@ sub create_json_coder {
# Override the JSON::RPC method to return our CGI object instead of theirs.
sub cgi { return Bugzilla->cgi; }
+sub response_header {
+ my $self = shift;
+ # The HTTP body needs to be bytes (not a utf8 string) for recent
+ # versions of HTTP::Message, but JSON::RPC::Server doesn't handle this
+ # properly. $_[1] is the HTTP body content we're going to be sending.
+ if (utf8::is_utf8($_[1])) {
+ utf8::encode($_[1]);
+ # Since we're going to just be sending raw bytes, we need to
+ # set STDOUT to not expect utf8.
+ disable_utf8();
+ }
+ return $self->SUPER::response_header(@_);
+}
+
sub response {
my ($self, $response) = @_;