summaryrefslogtreecommitdiffstats
path: root/extensions/SecureMail
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2014-11-27 15:22:17 +0100
committerByron Jones <glob@mozilla.com>2014-11-27 15:22:17 +0100
commit1aa5e76d25f0eb1d9d59909b486d9549458c95f0 (patch)
tree7fff051b65ba6fa541ce8d46543e4b1d2a034a43 /extensions/SecureMail
parent412b8264dd8b7832e273be8e887df2c47c46b297 (diff)
downloadbugzilla-1aa5e76d25f0eb1d9d59909b486d9549458c95f0.tar.gz
bugzilla-1aa5e76d25f0eb1d9d59909b486d9549458c95f0.tar.xz
Bug 1092578: Decide if an email needs to be encrypted at the time it is generated, not at the time it is sent
Diffstat (limited to 'extensions/SecureMail')
-rw-r--r--extensions/SecureMail/Extension.pm43
1 files changed, 28 insertions, 15 deletions
diff --git a/extensions/SecureMail/Extension.pm b/extensions/SecureMail/Extension.pm
index 492ce0cb6..90fafc06f 100644
--- a/extensions/SecureMail/Extension.pm
+++ b/extensions/SecureMail/Extension.pm
@@ -248,6 +248,25 @@ sub _send_test_email {
##############################################################################
# Encrypting the email
##############################################################################
+
+# determine if the bug should be encrypted at the time it is generated
+sub bugmail_enqueue {
+ my ($self, $args) = @_;
+ my $vars = $args->{vars};
+ if (_should_secure_bug($vars->{bug})) {
+ $vars->{bugzilla_encrypt} = 1;
+ }
+}
+
+sub bugmail_generate {
+ my ($self, $args) = @_;
+ my $vars = $args->{vars};
+ my $email = $args->{email};
+ if ($vars->{bugzilla_encrypt}) {
+ $email->header_set('X-Bugzilla-Encrypt', 1);
+ }
+}
+
sub mailer_before_send {
my ($self, $args) = @_;
@@ -556,7 +575,11 @@ sub _make_secure {
# Note: the $bug_id is required within the parentheses in order to keep
# gmail's threading algorithm happy.
$subject =~ s/($bug_id\])\s+(.*)$/$1$new (Secure bug $bug_id in $product :: $component)/;
- $email->header_set('Subject', $subject);
+ {
+ # avoid excessive line wrapping done by Encode.
+ local $Encode::Encoding{'MIME-Q'}->{'bpl'} = 998;
+ $email->header_set('Subject', encode('MIME-Q', $subject));
+ }
}
}
@@ -581,21 +604,18 @@ sub _pgp_encrypt {
# Insert the subject into the part's body, as the subject of the message will
# be sanitised.
# XXX this incorrectly assumes all parts of the message are the body
-# we should only alter parts who's parent is multipart/alternative
+# we should only alter parts whose parent is multipart/alternative
sub _insert_subject {
my ($part, $subject) = @_;
my $content_type = $part->content_type or return;
if ($content_type =~ /^text\/plain/) {
- if (!is_7bit_clean($subject)) {
- $part->encoding_set('quoted-printable');
- }
$part->body_str_set("Subject: $subject\015\012\015\012" . $part->body_str);
}
elsif ($content_type =~ /^text\/html/) {
my $tree = HTML::Tree->new->parse_content($part->body_str);
my $body = $tree->look_down(qw(_tag body));
- $body->unshift_content(['div', "Subject: $subject"], ['br']);
- _set_body_from_tree($part, $tree);
+ $body->unshift_content(['h1', "Subject: $subject"], ['br']);
+ $part->body_str_set($tree->as_HTML);
}
}
@@ -644,16 +664,9 @@ sub _filter_bug_links {
}
}
if ($updated) {
- _set_body_from_tree($part, $tree);
+ $part->body_str_set($tree->as_HTML);
}
});
}
-sub _set_body_from_tree {
- my ($part, $tree) = @_;
- $part->body_set($tree->as_HTML);
- $part->charset_set('UTF-8') if Bugzilla->params->{'utf8'};
- $part->encoding_set('quoted-printable');
-}
-
__PACKAGE__->NAME;