diff options
author | myk%mozilla.org <> | 2005-07-30 09:46:39 +0200 |
---|---|---|
committer | myk%mozilla.org <> | 2005-07-30 09:46:39 +0200 |
commit | d79c2c86ef0b69c4250642e3709f22a34fe7c8a0 (patch) | |
tree | d62dc2bd3405c4bda8ec94a65f9e29d2eabd8969 /attachment.cgi | |
parent | f55027e7a07f4cb3f74cd6c42e710e794564df3c (diff) | |
download | bugzilla-d79c2c86ef0b69c4250642e3709f22a34fe7c8a0.tar.gz bugzilla-d79c2c86ef0b69c4250642e3709f22a34fe7c8a0.tar.xz |
Fix for bug 302083: automatically converts BMP files to PNG files to conserve disk space; patch by Greg Hendricks; r=myk, a=myk
Diffstat (limited to 'attachment.cgi')
-rwxr-xr-x | attachment.cgi | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/attachment.cgi b/attachment.cgi index e4cbe8eed..1ed7a2322 100755 --- a/attachment.cgi +++ b/attachment.cgi @@ -24,6 +24,7 @@ # Dave Miller <justdave@syndicomm.com> # Alexander J. Vincent <ajvincent@juno.com> # Max Kanat-Alexander <mkanat@bugzilla.org> +# Greg Hendricks <ghendricks@novell.com> ################################################################################ # Script Initialization @@ -335,7 +336,22 @@ sub validateData $data || ($cgi->param('bigfile')) || ThrowUserError("zero_length_file"); - + + # Windows screenshots are usually uncompressed BMP files which + # makes for a quick way to eat up disk space. Let's compress them. + # We do this before we check the size since the uncompressed version + # could easily be greater than maxattachmentsize. + if (Param('convert_uncompressed_images') && $cgi->param('contenttype') eq 'image/bmp'){ + require Image::Magick; + my $img = Image::Magick->new(magick=>'bmp'); + $img->BlobToImage($data); + $img->set(magick=>'png'); + my $imgdata = $img->ImageToBlob(); + $data = $imgdata; + $cgi->param('contenttype', 'image/png'); + $vars->{'convertedbmp'} = 1; + } + # Make sure the attachment does not exceed the maximum permitted size my $len = $data ? length($data) : 0; if ($maxsize && $len > $maxsize) { @@ -891,9 +907,11 @@ sub insert ValidateComment(scalar $cgi->param('comment')); my $filename = validateFilename(); validateIsPatch(); - my $data = validateData(); validateDescription(); + # need to validate content type before data as + # we now check the content type for image/bmp in validateData() validateContentType() unless $cgi->param('ispatch'); + my $data = validateData(); my @obsolete_ids = (); @obsolete_ids = validateObsolete() if $cgi->param('obsolete'); |