diff options
author | Byron Jones <glob@mozilla.com> | 2014-10-23 07:50:46 +0200 |
---|---|---|
committer | Byron Jones <glob@mozilla.com> | 2014-10-23 07:50:46 +0200 |
commit | 6dc2473b8b5488b6c3ebd996128e5b79bd6421fc (patch) | |
tree | 5a47329c826135c3d99c1c76a3c5b7f9be20b332 /extensions/Profanivore | |
parent | d70f291452823c23cef444e8562bba97c5ac8cd7 (diff) | |
download | bugzilla-6dc2473b8b5488b6c3ebd996128e5b79bd6421fc.tar.gz bugzilla-6dc2473b8b5488b6c3ebd996128e5b79bd6421fc.tar.xz |
Bug 1078314: Missing links and broken unicode characters in some bugmail
Diffstat (limited to 'extensions/Profanivore')
-rw-r--r-- | extensions/Profanivore/Extension.pm | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/extensions/Profanivore/Extension.pm b/extensions/Profanivore/Extension.pm index cdec6e1c6..49b2f61c3 100644 --- a/extensions/Profanivore/Extension.pm +++ b/extensions/Profanivore/Extension.pm @@ -23,6 +23,7 @@ package Bugzilla::Extension::Profanivore; use strict; use base qw(Bugzilla::Extension); +use Email::MIME::ContentType qw(parse_content_type); use Regexp::Common 'RE_ALL'; use Bugzilla::Util qw(is_7bit_clean); @@ -117,17 +118,26 @@ sub mailer_before_send { sub _fix_encoding { my $part = shift; - my $body = $part->body; - if (Bugzilla->params->{'utf8'}) { + + # don't touch the top-level part of multi-part mail + return if $part->parts > 1; + + # nothing to do if the part already has a charset + my $ct = parse_content_type($part->content_type); + my $charset = $ct->{attributes}{charset} + ? $ct->{attributes}{charset} + : ''; + return unless !$charset || $charset eq 'us-ascii'; + + if (Bugzilla->params->{utf8}) { $part->charset_set('UTF-8'); - # encoding_set works only with bytes, not with utf8 strings. my $raw = $part->body_raw; if (utf8::is_utf8($raw)) { utf8::encode($raw); $part->body_set($raw); } } - $part->encoding_set('quoted-printable') if !is_7bit_clean($body); + $part->encoding_set('quoted-printable'); } sub _filter_text { |