[Rt-commit] rt branch, 4.2/forward-signed-mail, created. rt-4.2.10-237-g5323d6c
Alex Vandiver
alexmv at bestpractical.com
Thu Apr 9 16:44:09 EDT 2015
The branch, 4.2/forward-signed-mail has been created
at 5323d6c74751f89923e4b4822554e53999d3e7db (commit)
- Log -----------------------------------------------------------------
commit 64fd3186f98122badc073d10773cde2bd1c418c8
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Apr 10 18:13:57 2014 -0400
Ensure that message/rfc822 parts have no transfer encoding
RFC 1341 (http://tools.ietf.org/html/rfc1341#page-37) notes that
message/rfc822 parts must not have a Content-Transfer-Encoding. Weigh
this against RFC 3156 (http://tools.ietf.org/html/rfc3156#section-3),
which notes that all signed parts must not have any high bits set.
Previously, RT set a transfer encoding on all parts during signing,
obeying RFC 3156, but -- in the case of forwarded messages -- violating
RFC 1341.
Switch to putting a content-transfer-encoding on all parts assembled via
ContentAsMIME, which is used in forwards. This allows us to correctly
skip adding a content-transfer-encoding header on message/* parts
themselves.
Fixes I#13978.
diff --git a/lib/RT/Crypt/GnuPG.pm b/lib/RT/Crypt/GnuPG.pm
index ddb91e4..e1a4051 100644
--- a/lib/RT/Crypt/GnuPG.pm
+++ b/lib/RT/Crypt/GnuPG.pm
@@ -456,6 +456,7 @@ sub SignEncryptRFC3156 {
if ( $args{'Sign'} && !$args{'Encrypt'} ) {
# required by RFC3156(Ch. 5) and RFC1847(Ch. 2.1)
foreach ( grep !$_->is_multipart, $entity->parts_DFS ) {
+ next if $_->effective_type =~ m{^message/};
my $tenc = $_->head->mime_encoding;
unless ( $tenc =~ m/^(?:7bit|quoted-printable|base64)$/i ) {
$_->head->mime_attr( 'Content-Transfer-Encoding'
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index d909171..e5f7063 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -718,10 +718,21 @@ sub ContentAsMIME {
my $top = $attachments->First;
return unless $top;
- my $entity = MIME::Entity->build(
+ my $entity = $top->ContentAsMIME(Children => 1);
+ foreach ( grep !$_->is_multipart, $entity->parts_DFS ) {
+ next if $_->effective_type =~ m{^message/};
+ my $tenc = $_->head->mime_encoding;
+ unless ( $tenc =~ m/^(?:7bit|quoted-printable|base64)$/i ) {
+ $_->head->mime_attr( 'Content-Transfer-Encoding'
+ => $_->effective_type =~ m{^text/}? 'quoted-printable': 'base64'
+ );
+ }
+ }
+
+ $entity = MIME::Entity->build(
Type => 'message/rfc822',
Description => 'transaction ' . $self->id,
- Data => $top->ContentAsMIME(Children => 1)->as_string,
+ Data => $entity->as_string,
);
return $entity;
commit 5323d6c74751f89923e4b4822554e53999d3e7db
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Apr 10 18:40:36 2014 -0400
Default the content-transfer-encoding to 8bit
RT sets a content-transfer-encoding of 8bit on the top-level of outgoing
email, in RT::Interface::Email::SendEmail. This sets the default for
the entire message. Unfortunately, MIME::Entity is not aware of this,
and assumes that a lack of content-transfer-encoding header in any
particular part means it should default to 7bit.
These combine, in the case of signed email, to cause the "put a
content-transfer-encoding header" loop to mistakenly believe that a part
with 8bit data is actually 7bit, and thus it is left with no
content-transfer-encoding.
Assume that all unmarked parts are 8bit, as that is what the top-most
header implies anyway. This causes RT to correctly apply a transfer
encoding to 8bit data in signed messages.
diff --git a/lib/RT/Crypt/GnuPG.pm b/lib/RT/Crypt/GnuPG.pm
index e1a4051..e4a67bf 100644
--- a/lib/RT/Crypt/GnuPG.pm
+++ b/lib/RT/Crypt/GnuPG.pm
@@ -457,7 +457,8 @@ sub SignEncryptRFC3156 {
# required by RFC3156(Ch. 5) and RFC1847(Ch. 2.1)
foreach ( grep !$_->is_multipart, $entity->parts_DFS ) {
next if $_->effective_type =~ m{^message/};
- my $tenc = $_->head->mime_encoding;
+ my $tenc = $_->head->mime_attr('content-transfer-encoding')
+ ? $_->head->mime_encoding : '8bit';
unless ( $tenc =~ m/^(?:7bit|quoted-printable|base64)$/i ) {
$_->head->mime_attr( 'Content-Transfer-Encoding'
=> $_->effective_type =~ m{^text/}? 'quoted-printable': 'base64'
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index e5f7063..3f493ee 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -721,7 +721,8 @@ sub ContentAsMIME {
my $entity = $top->ContentAsMIME(Children => 1);
foreach ( grep !$_->is_multipart, $entity->parts_DFS ) {
next if $_->effective_type =~ m{^message/};
- my $tenc = $_->head->mime_encoding;
+ my $tenc = $_->head->mime_attr('content-transfer-encoding')
+ ? $_->head->mime_encoding : '8bit';
unless ( $tenc =~ m/^(?:7bit|quoted-printable|base64)$/i ) {
$_->head->mime_attr( 'Content-Transfer-Encoding'
=> $_->effective_type =~ m{^text/}? 'quoted-printable': 'base64'
-----------------------------------------------------------------------
More information about the rt-commit
mailing list