Commit cee67bdc authored by Max Kanat-Alexander's avatar Max Kanat-Alexander

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
parent 04a0f6e7
...@@ -112,6 +112,10 @@ use constant VALIDATORS => { ...@@ -112,6 +112,10 @@ use constant VALIDATORS => {
mimetype => \&_check_content_type, mimetype => \&_check_content_type,
}; };
use constant VALIDATOR_DEPENDENCIES => {
mimetype => ['ispatch'],
};
use constant UPDATE_VALIDATORS => { use constant UPDATE_VALIDATORS => {
isobsolete => \&Bugzilla::Object::check_boolean, isobsolete => \&Bugzilla::Object::check_boolean,
}; };
...@@ -508,9 +512,10 @@ sub _check_bug { ...@@ -508,9 +512,10 @@ sub _check_bug {
} }
sub _check_content_type { sub _check_content_type {
my ($invocant, $content_type) = @_; my ($invocant, $content_type, undef, $params) = @_;
$content_type = 'text/plain' if (ref $invocant && $invocant->ispatch); my $is_patch = ref($invocant) ? $invocant->ispatch : $params->{ispatch};
$content_type = 'text/plain' if $is_patch;
$content_type = trim($content_type); $content_type = trim($content_type);
my $legal_types = join('|', LEGAL_CONTENT_TYPES); my $legal_types = join('|', LEGAL_CONTENT_TYPES);
if (!$content_type or $content_type !~ /^($legal_types)\/.+$/) { if (!$content_type or $content_type !~ /^($legal_types)\/.+$/) {
......
...@@ -2446,6 +2446,10 @@ You did not specify a valid for the C<file_name> argument. ...@@ -2446,6 +2446,10 @@ You did not specify a valid for the C<file_name> argument.
You did not specify a value for the C<summary> argument. You did not specify a value for the C<summary> argument.
=item 606 (Empty Data)
You set the "data" field to an empty string.
=back =back
=item B<History> =item B<History>
......
...@@ -148,6 +148,7 @@ use constant WS_ERROR_CODE => { ...@@ -148,6 +148,7 @@ use constant WS_ERROR_CODE => {
file_not_specified => 603, file_not_specified => 603,
missing_attachment_description => 604, missing_attachment_description => 604,
# Error 605 attachment_url_disabled no longer exists. # Error 605 attachment_url_disabled no longer exists.
zero_length_file => 606,
# Errors thrown by the WebService itself. The ones that are negative # Errors thrown by the WebService itself. The ones that are negative
# conform to http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php # conform to http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment