summaryrefslogtreecommitdiffstats
path: root/attachment.cgi
diff options
context:
space:
mode:
authorKohei Yoshino <kohei.yoshino@gmail.com>2018-08-10 14:56:19 +0200
committerDylan William Hardison <dylan@hardison.net>2018-08-10 14:56:19 +0200
commit5a43b27f7940be9697f312c550fa2de11a9e14d7 (patch)
tree9e6e91abf14d1052366b8815b0fa63f4a0655372 /attachment.cgi
parent1f35e100eaab5776633a3b995f3c32a0438f6e86 (diff)
downloadbugzilla-5a43b27f7940be9697f312c550fa2de11a9e14d7.tar.gz
bugzilla-5a43b27f7940be9697f312c550fa2de11a9e14d7.tar.xz
Bug 602313 - Allow creation of attachments by pasting an image from clipboard, as well as by drag-and-dropping a file from desktop
Diffstat (limited to 'attachment.cgi')
-rwxr-xr-xattachment.cgi15
1 files changed, 13 insertions, 2 deletions
diff --git a/attachment.cgi b/attachment.cgi
index d1b260407..875de6a50 100755
--- a/attachment.cgi
+++ b/attachment.cgi
@@ -33,6 +33,7 @@ use URI;
use URI::QueryParam;
use URI::Escape qw(uri_escape_utf8);
use File::Basename qw(basename);
+use MIME::Base64 qw(decode_base64);
# For most scripts we don't make $cgi and $template global variables. But
# when preparing Bugzilla for mod_perl, this script used these
@@ -552,20 +553,30 @@ sub insert {
# Get the filehandle of the attachment.
my $data_fh = $cgi->upload('data');
my $attach_text = $cgi->param('attach_text');
+ my $data_base64 = $cgi->param('data_base64');
+ my $data;
+ my $filename;
if ($attach_text) {
# Convert to unix line-endings if pasting a patch
if (scalar($cgi->param('ispatch'))) {
$attach_text =~ s/[\012\015]{1,2}/\012/g;
}
+ $data = $attach_text;
+ $filename = "file_$bugid.txt";
+ } elsif ($data_base64) {
+ $data = decode_base64($data_base64);
+ $filename = $cgi->param('filename') || "file_$bugid";
+ } else {
+ $data = $filename = $data_fh;
}
my $attachment = Bugzilla::Attachment->create(
{bug => $bug,
creation_ts => $timestamp,
- data => $attach_text || $data_fh,
+ data => $data,
description => scalar $cgi->param('description'),
- filename => $attach_text ? "file_$bugid.txt" : $data_fh,
+ filename => $filename,
ispatch => scalar $cgi->param('ispatch'),
isprivate => scalar $cgi->param('isprivate'),
mimetype => $content_type,