[Rt-commit] rt branch, 4.0/encode-2.53-support, created. rt-4.0.17-88-gd469cac
Alex Vandiver
alexmv at bestpractical.com
Fri Sep 27 14:57:10 EDT 2013
The branch, 4.0/encode-2.53-support has been created
at d469cacc105aeb21999aaee151253485d9f48e99 (commit)
- Log -----------------------------------------------------------------
commit d469cacc105aeb21999aaee151253485d9f48e99
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Sep 27 14:30:39 2013 -0400
Ensure that the Subject header is not double-encoded
In Encode 2.52 and below, `decode_utf8(...)` called on a string with the
internal utf8" flag (i.e. containing characters, not bytes) was a no-op.
Encode 2.53 changed this, for parity with `decode('utf8', ...)`
The contents of the 'Subject' header when sending mail were usually
bytes, as parsed by MIME-Tools. As such, before adding the subject tag,
they were decoded into characters. However, in the case where no
Subject was given by the template (for example, the "Transaction"
template), RT generated a (wide-character) string for the Subject based
on the ticket title, and inserted it into the MIME object. Later,
before the subject tag was added decode_utf8() was called on this wide
string -- and prior to Encode 2.53, this was a no-op.
Ensure that the values placed in the MIME header are always bytes, and
not wide characters. There are two changes to do this: first, ensure
that the automatically-generated subject is encoded before being used;
and second, that the string with the subject tag is re-encoded before
the header is set to it.
diff --git a/lib/RT/Action/SendEmail.pm b/lib/RT/Action/SendEmail.pm
index 0ff7e6d..ca6d10d 100644
--- a/lib/RT/Action/SendEmail.pm
+++ b/lib/RT/Action/SendEmail.pm
@@ -972,7 +972,7 @@ sub SetSubject {
$subject =~ s/(\r\n|\n|\s)/ /g;
- $self->SetHeader( 'Subject', $subject );
+ $self->SetHeader( 'Subject', Encode::encode_utf8( $subject ) );
}
@@ -986,11 +986,14 @@ sub SetSubjectToken {
my $self = shift;
my $head = $self->TemplateObj->MIMEObj->head;
- $head->replace(
- Subject => RT::Interface::Email::AddSubjectTag(
- Encode::decode_utf8( $head->get('Subject') ),
- $self->TicketObj,
- ),
+ $self->SetHeader(
+ Subject =>
+ Encode::encode_utf8(
+ RT::Interface::Email::AddSubjectTag(
+ Encode::decode_utf8( $head->get('Subject') ),
+ $self->TicketObj,
+ ),
+ ),
);
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list