From: Max Kanat-Alexander Date: Fri, 11 Feb 2011 00:28:31 +0000 (-0800) Subject: Bug 633041: Add an error code for zero_length_file and fill in content_type X-Git-Tag: bugzilla-4.0~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3cfd395f2d76aef9d7d6fe4ecd8e5e4ae284230e;p=thirdparty%2Fbugzilla.git Bug 633041: Add an error code for zero_length_file and fill in content_type for patches when content_type is missing in Bug.add_attachment in the WebService r=LpSolit, a=LpSolit --- diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm index adc6ddcf2c..79f7b915e4 100644 --- a/Bugzilla/Attachment.pm +++ b/Bugzilla/Attachment.pm @@ -111,6 +111,10 @@ use constant VALIDATORS => { store_in_file => \&_check_store_in_file, }; +use constant VALIDATOR_DEPENDENCIES => { + mimetype => ['ispatch', 'isurl'], +}; + use constant UPDATE_VALIDATORS => { filename => \&_check_filename, isobsolete => \&Bugzilla::Object::check_boolean, @@ -523,9 +527,15 @@ sub _check_bug { } sub _check_content_type { - my ($invocant, $content_type) = @_; + my ($invocant, $content_type, undef, $params) = @_; + + my ($is_url, $is_patch) = @$params{qw(isurl ispatch)}; + if (ref $invocant) { + $is_url = $invocant->isurl; + $is_patch = $invocant->ispatch; + } - $content_type = 'text/plain' if (ref $invocant && ($invocant->isurl || $invocant->ispatch)); + $content_type = 'text/plain' if ($is_url || $is_patch); $content_type = trim($content_type); my $legal_types = join('|', LEGAL_CONTENT_TYPES); if (!$content_type or $content_type !~ /^($legal_types)\/.+$/) { diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index 43719f9930..8bec963046 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -2463,6 +2463,10 @@ You did not specify a value for the C argument. You attempted to attach a URL, setting C to True, but this Bugzilla does not support attaching URLs. +=item 606 (Empty Data) + +You set the "data" field to an empty string. + =back =back diff --git a/Bugzilla/WebService/Constants.pm b/Bugzilla/WebService/Constants.pm index 8fbc7c0979..ac4aa712eb 100644 --- a/Bugzilla/WebService/Constants.pm +++ b/Bugzilla/WebService/Constants.pm @@ -150,6 +150,7 @@ use constant WS_ERROR_CODE => { file_not_specified => 603, missing_attachment_description => 604, attachment_url_disabled => 605, + zero_length_file => 606, # Errors thrown by the WebService itself. The ones that are negative # conform to http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php