summaryrefslogtreecommitdiffstats
path: root/extensions/Splinter/lib
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2014-10-23 07:50:46 +0200
committerByron Jones <glob@mozilla.com>2014-10-23 07:50:46 +0200
commit6dc2473b8b5488b6c3ebd996128e5b79bd6421fc (patch)
tree5a47329c826135c3d99c1c76a3c5b7f9be20b332 /extensions/Splinter/lib
parentd70f291452823c23cef444e8562bba97c5ac8cd7 (diff)
downloadbugzilla-6dc2473b8b5488b6c3ebd996128e5b79bd6421fc.tar.gz
bugzilla-6dc2473b8b5488b6c3ebd996128e5b79bd6421fc.tar.xz
Bug 1078314: Missing links and broken unicode characters in some bugmail
Diffstat (limited to 'extensions/Splinter/lib')
-rw-r--r--extensions/Splinter/lib/Util.pm33
1 files changed, 31 insertions, 2 deletions
diff --git a/extensions/Splinter/lib/Util.pm b/extensions/Splinter/lib/Util.pm
index 3c77239a9..e6cbe7493 100644
--- a/extensions/Splinter/lib/Util.pm
+++ b/extensions/Splinter/lib/Util.pm
@@ -25,6 +25,7 @@ use strict;
use Bugzilla;
use Bugzilla::Util;
+use Email::MIME::ContentType qw(parse_content_type);
use base qw(Exporter);
@@ -130,7 +131,11 @@ sub munge_create_attachment {
# (\015 and \012 are used because Perl \n is platform-dependent)
sub add_review_links_to_email {
my $email = shift;
- my $body = $email->body;
+ return if $email->parts > 1;
+
+ _fix_encoding($email);
+ my $body = $email->body_str;
+
my $new_body = 0;
my $bug;
@@ -157,7 +162,31 @@ sub add_review_links_to_email {
$new_body = 1;
}
- $email->body_set($body) if $new_body;
+ $email->body_str_set($body) if $new_body;
+}
+
+sub _fix_encoding {
+ my $part = shift;
+
+ # 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');
+ my $raw = $part->body_raw;
+ if (utf8::is_utf8($raw)) {
+ utf8::encode($raw);
+ $part->body_set($raw);
+ }
+ }
+ $part->encoding_set('quoted-printable');
}
1;