diff options
author | Max Magorsch <arzano@gentoo.org> | 2020-05-06 23:08:16 +0200 |
---|---|---|
committer | Max Magorsch <arzano@gentoo.org> | 2020-05-06 23:08:16 +0200 |
commit | a14117fb61e561823faccbe9842e7debe16368cb (patch) | |
tree | f7c2bc1ffbd635ac74357f6c437da1e682e5f33a | |
parent | Update arch states (diff) | |
download | bugzilla-a14117fb61e561823faccbe9842e7debe16368cb.tar.gz bugzilla-a14117fb61e561823faccbe9842e7debe16368cb.tar.bz2 bugzilla-a14117fb61e561823faccbe9842e7debe16368cb.zip |
Add the AttachmentFilter extension
The extension can be used to filter attachments.
Currently it's filtering html attachments, based on the
mime-type and the filename.
The extension is currently disabled.
Signed-off-by: Max Magorsch <arzano@gentoo.org>
-rw-r--r-- | extensions/AttachmentFilter/Config.pm | 15 | ||||
-rw-r--r-- | extensions/AttachmentFilter/Extension.pm | 28 | ||||
-rw-r--r-- | extensions/AttachmentFilter/disabled | 0 |
3 files changed, 43 insertions, 0 deletions
diff --git a/extensions/AttachmentFilter/Config.pm b/extensions/AttachmentFilter/Config.pm new file mode 100644 index 000000000..5810b5d87 --- /dev/null +++ b/extensions/AttachmentFilter/Config.pm @@ -0,0 +1,15 @@ +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# This extension is filtering attachments. +# +# Currently its is filtering html attachments. +# +# Contributor(s): +# Max Magorsch <arzano@gentoo.org> + +package Bugzilla::Extension::AttachmentFilter; +use strict; + +use constant NAME => 'AttachmentFilter'; + +__PACKAGE__->NAME; diff --git a/extensions/AttachmentFilter/Extension.pm b/extensions/AttachmentFilter/Extension.pm new file mode 100644 index 000000000..1d316901e --- /dev/null +++ b/extensions/AttachmentFilter/Extension.pm @@ -0,0 +1,28 @@ +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# This extension is filtering attachments. +# +# Currently its is filtering html attachments. +# +# Contributor(s): +# Max Magorsch <arzano@gentoo.org> + +package Bugzilla::Extension::AttachmentFilter; +use strict; +use base qw(Bugzilla::Extension); + +our $VERSION = '0.01'; +################################################################################ +# This extension is filtering attachments. Currently its is filtering html +# attachments. +################################################################################ +sub attachment_process_data { + my ($self, $args) = @_; + return unless ( ($args->{attributes}->{mimetype} eq 'text/html') or ($args->{attributes}->{filename} =~ /\.htm\z/) or ($args->{attributes}->{filename} =~ /\.html\z/) ); + + ${$args->{data}} = ''; + $args->{attributes}->{filename} = ''; + +} + +__PACKAGE__->NAME; diff --git a/extensions/AttachmentFilter/disabled b/extensions/AttachmentFilter/disabled new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/extensions/AttachmentFilter/disabled |