summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2010-07-18 19:17:26 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2010-07-18 19:17:26 +0200
commit2addcaadedfe714bd0502911cc85cdab24736465 (patch)
tree0e58e2ce48866cdf7198d7d45df1348bf1e0859a /Bugzilla
parentaef5cb18c3f2f6e1a438faed08e944af9db4847c (diff)
downloadbugzilla-2addcaadedfe714bd0502911cc85cdab24736465.tar.gz
bugzilla-2addcaadedfe714bd0502911cc85cdab24736465.tar.xz
Bug 119703: Create an attachment by pasting it into a text field
r/a=mkanat
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Attachment.pm56
-rw-r--r--Bugzilla/Config/Attachment.pm5
-rw-r--r--Bugzilla/DB/Schema.pm2
-rw-r--r--Bugzilla/Field.pm1
-rw-r--r--Bugzilla/Install/DB.pm19
-rw-r--r--Bugzilla/WebService/Bug.pm35
-rw-r--r--Bugzilla/WebService/Constants.pm4
7 files changed, 35 insertions, 87 deletions
diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm
index 0f91d29c4..f63973875 100644
--- a/Bugzilla/Attachment.pm
+++ b/Bugzilla/Attachment.pm
@@ -83,7 +83,6 @@ sub DB_COLUMNS {
isobsolete
ispatch
isprivate
- isurl
mimetype
modification_time
submitter_id),
@@ -107,14 +106,13 @@ use constant UPDATE_COLUMNS => qw(
use constant VALIDATORS => {
bug => \&_check_bug,
description => \&_check_description,
+ filename => \&_check_filename,
ispatch => \&Bugzilla::Object::check_boolean,
isprivate => \&_check_is_private,
- isurl => \&_check_is_url,
mimetype => \&_check_content_type,
};
use constant UPDATE_VALIDATORS => {
- filename => \&_check_filename,
isobsolete => \&Bugzilla::Object::check_boolean,
};
@@ -268,21 +266,6 @@ sub ispatch {
=over
-=item C<isurl>
-
-whether or not the attachment is a URL
-
-=back
-
-=cut
-
-sub isurl {
- my $self = shift;
- return $self->{isurl};
-}
-
-=over
-
=item C<isobsolete>
whether or not the attachment is obsolete
@@ -527,7 +510,7 @@ sub _check_bug {
sub _check_content_type {
my ($invocant, $content_type) = @_;
- $content_type = 'text/plain' if (ref $invocant && ($invocant->isurl || $invocant->ispatch));
+ $content_type = 'text/plain' if (ref $invocant && $invocant->ispatch);
my $legal_types = join('|', LEGAL_CONTENT_TYPES);
if (!$content_type or $content_type !~ /^($legal_types)\/.+$/) {
ThrowUserError("invalid_content_type", { contenttype => $content_type });
@@ -541,17 +524,8 @@ sub _check_data {
my ($invocant, $params) = @_;
my $data = $params->{data};
- if ($params->{isurl}) {
- ($data && $data =~ m#^(http|https|ftp)://\S+#)
- || ThrowUserError('attachment_illegal_url', { url => $data });
+ $params->{filesize} = ref $data ? -s $data : length($data);
- $params->{mimetype} = 'text/plain';
- $params->{ispatch} = 0;
- $params->{filesize} = length($data);
- }
- else {
- $params->{filesize} = ref $data ? -s $data : length($data);
- }
Bugzilla::Hook::process('attachment_process_data', { data => \$data,
attributes => $params });
@@ -576,11 +550,7 @@ sub _check_description {
}
sub _check_filename {
- my ($invocant, $filename, $is_url) = @_;
-
- $is_url = $invocant->isurl if ref $invocant;
- # No file is attached, so it has no name.
- return '' if $is_url;
+ my ($invocant, $filename) = @_;
$filename = trim($filename);
$filename || ThrowUserError('file_not_specified');
@@ -612,15 +582,6 @@ sub _check_is_private {
return $is_private;
}
-sub _check_is_url {
- my ($invocant, $is_url) = @_;
-
- if ($is_url && !Bugzilla->params->{'allow_attach_url'}) {
- ThrowCodeError('attachment_url_disabled');
- }
- return $is_url ? 1 : 0;
-}
-
=pod
=head2 Class Methods
@@ -783,8 +744,6 @@ Params: takes a hashref with the following keys:
attachment is a patch.
C<isprivate> - boolean (optional, default false) - true if
the attachment is private.
- C<isurl> - boolean (optional, default false) - true if the
- attachment is a URL pointing to some external ressource.
Returns: The new attachment object.
@@ -852,7 +811,6 @@ sub run_create_validators {
$params->{data} = $class->_check_data($params);
$params = $class->SUPER::run_create_validators($params);
- $params->{filename} = $class->_check_filename($params->{filename}, $params->{isurl});
$params->{creation_ts} ||= Bugzilla->dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
$params->{modification_time} = $params->{creation_ts};
$params->{submitter_id} = Bugzilla->user->id || ThrowCodeError('invalid_user');
@@ -917,8 +875,8 @@ sub remove_from_db {
$dbh->bz_start_transaction();
$dbh->do('DELETE FROM flags WHERE attach_id = ?', undef, $self->id);
$dbh->do('DELETE FROM attach_data WHERE id = ?', undef, $self->id);
- $dbh->do('UPDATE attachments SET mimetype = ?, ispatch = ?, isurl = ?, isobsolete = ?
- WHERE attach_id = ?', undef, ('text/plain', 0, 0, 1, $self->id));
+ $dbh->do('UPDATE attachments SET mimetype = ?, ispatch = ?, isobsolete = ?
+ WHERE attach_id = ?', undef, ('text/plain', 0, 1, $self->id));
$dbh->bz_commit_transaction();
}
@@ -930,7 +888,7 @@ sub remove_from_db {
sub get_content_type {
my $cgi = Bugzilla->cgi;
- return 'text/plain' if ($cgi->param('ispatch') || $cgi->param('attachurl'));
+ return 'text/plain' if ($cgi->param('ispatch') || $cgi->param('attach_text'));
my $content_type;
if (!defined $cgi->param('contenttypemethod')) {
diff --git a/Bugzilla/Config/Attachment.pm b/Bugzilla/Config/Attachment.pm
index ed4c4e459..e6e3b7f3d 100644
--- a/Bugzilla/Config/Attachment.pm
+++ b/Bugzilla/Config/Attachment.pm
@@ -58,11 +58,6 @@ sub get_param_list {
type => 'b',
default => 0
},
- {
- name => 'allow_attach_url',
- type => 'b',
- default => 0
- },
{
name => 'maxattachmentsize',
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index a00a7b9d9..a4d44d191 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -453,8 +453,6 @@ use constant ABSTRACT_SCHEMA => {
DEFAULT => 'FALSE'},
isprivate => {TYPE => 'BOOLEAN', NOTNULL => 1,
DEFAULT => 'FALSE'},
- isurl => {TYPE => 'BOOLEAN', NOTNULL => 1,
- DEFAULT => 'FALSE'},
],
INDEXES => [
attachments_bug_id_idx => ['bug_id'],
diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm
index c0e88fc37..484d6536a 100644
--- a/Bugzilla/Field.pm
+++ b/Bugzilla/Field.pm
@@ -238,7 +238,6 @@ use constant DEFAULT_FIELDS => (
buglist => 1},
{name => 'content', desc => 'Content'},
{name => 'attach_data.thedata', desc => 'Attachment data'},
- {name => 'attachments.isurl', desc => 'Attachment is a URL'},
{name => "owner_idle_time", desc => "Time Since Assignee Touched"},
{name => 'see_also', desc => "See Also",
type => FIELD_TYPE_BUG_URLS},
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index 225e862de..33f37208f 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -429,10 +429,6 @@ sub update_table_definitions {
# PUBLIC is a reserved word in Oracle.
$dbh->bz_rename_column('series', 'public', 'is_public');
- # 2005-09-28 bugreport@peshkin.net Bug 149504
- $dbh->bz_add_column('attachments', 'isurl',
- {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 0});
-
# 2005-10-21 LpSolit@gmail.com - Bug 313020
$dbh->bz_add_column('namedqueries', 'query_type',
{TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 0});
@@ -630,6 +626,9 @@ sub update_table_definitions {
$dbh->bz_alter_column('products', 'allows_unconfirmed',
{ TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'TRUE' });
+ # 2010-07-18 LpSolit@gmail.com - Bug 119703
+ _remove_attachment_isurl();
+
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################
@@ -3401,6 +3400,18 @@ sub _fix_series_creator_fk {
}
}
+sub _remove_attachment_isurl {
+ my $dbh = Bugzilla->dbh;
+
+ if ($dbh->bz_column_info('attachments', 'isurl')) {
+ # Now all attachments must have a filename.
+ $dbh->do('UPDATE attachments SET filename = ? WHERE isurl = 1',
+ undef, 'url.txt');
+ $dbh->bz_drop_column('attachments', 'isurl');
+ $dbh->do("DELETE FROM fielddefs WHERE name='attachments.isurl'");
+ }
+}
+
1;
__END__
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm
index 78709d81e..6065ee493 100644
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -623,7 +623,6 @@ sub add_attachment {
mimetype => $params->{content_type},
ispatch => $params->{is_patch},
isprivate => $params->{is_private},
- isurl => $params->{is_url},
});
my $comment = $params->{comment} || '';
$attachment->bug->add_comment($comment,
@@ -846,7 +845,6 @@ sub _attachment_to_hash {
content_type => $self->type('string', $attach->contenttype),
is_private => $self->type('int', $attach->isprivate),
is_obsolete => $self->type('int', $attach->isobsolete),
- is_url => $self->type('int', $attach->isurl),
is_patch => $self->type('int', $attach->ispatch),
creator => $self->type('string', $attach->attacher->login),
attacher => $self->type('string', $attach->attacher->login),
@@ -1231,13 +1229,6 @@ group called the "insidergroup"), False otherwise.
C<boolean> True if the attachment is obsolete, False otherwise.
-=item C<is_url>
-
-C<boolean> True if the attachment is a URL instead of actual data,
-False otherwise. Note that such attachments only happen when the
-Bugzilla installation has at some point had the C<allow_attach_url>
-parameter enabled.
-
=item C<is_patch>
C<boolean> True if the attachment is a patch, False otherwise.
@@ -1279,6 +1270,9 @@ C<creator>.
=item In Bugzilla B<4.0>, the C<description> return value was renamed to
C<summary>.
+=item In Bugzilla B<4.2>, the C<is_url> return value was removed
+(this attribute no longer exists for attachments).
+
=back
=back
@@ -2163,13 +2157,6 @@ to the "insidergroup"), False if the attachment should be public.
Defaults to False if not specified.
-=item C<is_url>
-
-C<boolean> True if the attachment is just a URL, pointing to data elsewhere.
-If so, the C<data> item should just contain the URL.
-
-Defaults to False if not specified.
-
=back
=item B<Returns>
@@ -2193,11 +2180,6 @@ You tried to attach a file that was larger than Bugzilla will accept.
You specified a C<content_type> argument that was blank, not a valid
MIME type, or not a MIME type that Bugzilla accepts for attachments.
-=item 602 (Illegal URL)
-
-You specified C<is_url> as True, but the data that you attempted
-to attach was not a valid URL.
-
=item 603 (File Name Not Specified)
You did not specify a valid for the C<file_name> argument.
@@ -2206,10 +2188,15 @@ You did not specify a valid for the C<file_name> argument.
You did not specify a value for the C<summary> argument.
-=item 605 (URL Attaching Disabled)
+=back
+
+=item B<History>
+
+=over
+
+=item Added in Bugzilla B<4.0>.
-You attempted to attach a URL, setting C<is_url> to True,
-but this Bugzilla does not support attaching URLs.
+=item The C<is_url> parameter was removed in Bugzilla B<4.2>.
=back
diff --git a/Bugzilla/WebService/Constants.pm b/Bugzilla/WebService/Constants.pm
index aec2b9855..f77c54c85 100644
--- a/Bugzilla/WebService/Constants.pm
+++ b/Bugzilla/WebService/Constants.pm
@@ -124,10 +124,10 @@ use constant WS_ERROR_CODE => {
# Attachment errors are 600-700.
file_too_large => 600,
invalid_content_type => 601,
- attachment_illegal_url => 602,
+ # Error 602 attachment_illegal_url no longer exists.
file_not_specified => 603,
missing_attachment_description => 604,
- attachment_url_disabled => 605,
+ # Error 605 attachment_url_disabled no longer exists.
# Errors thrown by the WebService itself. The ones that are negative
# conform to http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php