From 12eb7b79859d1ee0be9f237d2b097fc4bf42d2c3 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Tue, 13 Jul 2010 15:43:40 -0700 Subject: Bug 412074: Ability to add attachments to a bug via the WebService (Bug.add_attachment) r=timello, a=mkanat --- Bugzilla/WebService/Server/JSONRPC.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'Bugzilla/WebService/Server/JSONRPC.pm') diff --git a/Bugzilla/WebService/Server/JSONRPC.pm b/Bugzilla/WebService/Server/JSONRPC.pm index 5ab5e4a7b..3ff875361 100644 --- a/Bugzilla/WebService/Server/JSONRPC.pm +++ b/Bugzilla/WebService/Server/JSONRPC.pm @@ -27,9 +27,10 @@ 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 MIME::Base64 qw(decode_base64); + ##################################### # Public JSON::RPC Method Overrides # ##################################### @@ -326,6 +327,12 @@ sub _argument_type_check { } } } + my @base64_fields = @{ $pkg->BASE64_FIELDS->{$method} || [] }; + foreach my $field (@base64_fields) { + if (defined $params->{$field}) { + $params->{$field} = decode_base64($params->{$field}); + } + } Bugzilla->input_params($params); @@ -503,6 +510,11 @@ to be fully safe for forward-compatibility with all future versions of Bugzilla, it is safest to pass in all times as UTC with the "Z" timezone specifier.) +C fields are strings that have been base64 encoded. Note that +although normal base64 encoding includes newlines to break up the data, +newlines within a string are not valid JSON, so you should not insert +newlines into your base64-encoded string. + All other types are standard JSON types. =head1 ERRORS -- cgit v1.2.3-24-g4f1b