aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/Attachment.pm')
-rw-r--r--Bugzilla/Attachment.pm56
1 files changed, 7 insertions, 49 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')) {