]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 547601: Make the JSON-RPC interface return UTF-8 data correctly
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Sat, 27 Feb 2010 07:51:20 +0000 (23:51 -0800)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Sat, 27 Feb 2010 07:51:20 +0000 (23:51 -0800)
r=dkl, a=mkanat

Bugzilla/WebService/Server/JSONRPC.pm

index cc3e8058ecfc85a2a4d28997be6542b220d6b608..35eda1af1dba452275ed999a987b7df709110145 100644 (file)
@@ -35,13 +35,23 @@ sub new {
     Bugzilla->_json_server($self);
     $self->dispatch(WS_DISPATCH);
     $self->return_die_message(1);
-    $self->json->allow_blessed(1);
-    $self->json->convert_blessed(1);
     # Default to JSON-RPC 1.0
     $self->version(0);
     return $self;
 }
 
+sub create_json_coder {
+    my $self = shift;
+    my $json = $self->SUPER::create_json_coder(@_);
+    $json->allow_blessed(1);
+    $json->convert_blessed(1);
+    # This may seem a little backwards, but what this really means is
+    # "don't convert our utf8 into byte strings, just leave it as a
+    # utf8 string."
+    $json->utf8(0) if Bugzilla->params->{'utf8'};
+    return $json;
+}
+
 # Override the JSON::RPC method to return our CGI object instead of theirs.
 sub cgi { return Bugzilla->cgi; }