From ae25abcc31888afd2a5ca47e8d3d64c701155696 Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Thu, 23 Aug 2012 15:45:53 -0400 Subject: Bug 775275 - Port HTML email support from Bugzilla 4.2 to BMO 4.0 - Added fix for filter bug links issue ported to bmo/4.0 - Removed need to check for 4.2 for HTML::Tree --- extensions/SecureMail/Config.pm | 46 +++++++++++++++----------------------- extensions/SecureMail/Extension.pm | 15 +++++-------- 2 files changed, 24 insertions(+), 37 deletions(-) diff --git a/extensions/SecureMail/Config.pm b/extensions/SecureMail/Config.pm index df7d5d928..5b53ddf67 100644 --- a/extensions/SecureMail/Config.pm +++ b/extensions/SecureMail/Config.pm @@ -22,36 +22,26 @@ package Bugzilla::Extension::SecureMail; use strict; -use Bugzilla::Constants; -use Bugzilla::Install::Util qw(vers_cmp); - use constant NAME => 'SecureMail'; -sub REQUIRED_MODULES { - my $modules = [ - { - package => 'Crypt-OpenPGP', - module => 'Crypt::OpenPGP', - # 1.02 added the ability for new() to take KeyRing objects for the - # PubRing argument. - version => '1.02', - }, - { - package => 'Crypt-SMIME', - module => 'Crypt::SMIME', - version => 0, - }, - ]; - if (vers_cmp(BUGZILLA_VERSION, '4.2') > -1) { - push(@$modules, - { - package => 'HTML-Tree', - module => 'HTML::Tree', - version => 0, - } - ); +use constant REQUIRED_MODULES => [ + { + package => 'Crypt-OpenPGP', + module => 'Crypt::OpenPGP', + # 1.02 added the ability for new() to take KeyRing objects for the + # PubRing argument. + version => '1.02', + }, + { + package => 'Crypt-SMIME', + module => 'Crypt::SMIME', + version => 0, + }, + { + package => 'HTML-Tree', + module => 'HTML::Tree', + version => 0, } - return $modules; -} +]; __PACKAGE__->NAME; diff --git a/extensions/SecureMail/Extension.pm b/extensions/SecureMail/Extension.pm index 2138864e0..d4d29b5c0 100644 --- a/extensions/SecureMail/Extension.pm +++ b/extensions/SecureMail/Extension.pm @@ -46,12 +46,6 @@ use constant SECURE_NONE => 0; use constant SECURE_BODY => 1; use constant SECURE_ALL => 2; -our $FILTER_BUG_LINKS = 1; -if(vers_cmp(BUGZILLA_VERSION, '4.2') > -1) { - eval "require HTML::Tree"; - $FILTER_BUG_LINKS = 0 if $@; -} - ############################################################################## # Creating new columns # @@ -305,7 +299,7 @@ sub mailer_before_send { # Filter the bug_links in HTML email in case the bugs the links # point are "secured" bugs and the user may not be able to see # the summaries. - _filter_bug_links($email) if $FILTER_BUG_LINKS; + _filter_bug_links($email); } else { _make_secure($email, $public_key, $is_bugmail && $make_secure == SECURE_ALL, $add_new); @@ -534,7 +528,7 @@ sub _filter_bug_links { $email->walk_parts(sub { my $part = shift; return if $part->content_type !~ /text\/html/; - my$body = $part->body; + my $body = $part->body; my $tree = HTML::Tree->new->parse_content($body); my @links = $tree->look_down( _tag => q{a}, class => qr/bz_bug_link/ ); foreach my $link (@links) { @@ -546,7 +540,10 @@ sub _filter_bug_links { $link->attr('class', 'bz_bug_link'); } } - $part->body_set($tree->as_HTML); + $body = $tree->as_HTML; + $part->body_set($body); + $part->charset_set('UTF-8') if Bugzilla->params->{'utf8'}; + $part->encoding_set('quoted-printable'); }); } -- cgit v1.2.3-24-g4f1b