summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2009-02-22 01:44:25 +0100
committermkanat%bugzilla.org <>2009-02-22 01:44:25 +0100
commit367a969471b0f8ae940410f97beae4e300d0b81d (patch)
treed1aee560a2cfaf9a496b2b679aa689cd52a3da86
parent9ae356d7ce269f120c815705f41e93e266d5a75a (diff)
downloadbugzilla-367a969471b0f8ae940410f97beae4e300d0b81d.tar.gz
bugzilla-367a969471b0f8ae940410f97beae4e300d0b81d.tar.xz
Bug 467920: Remove multiple CRs in a row from the email template and make sure all email lines end in CRLF.
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=glob, a=mkanat
-rw-r--r--Bugzilla/Mailer.pm15
1 files changed, 14 insertions, 1 deletions
diff --git a/Bugzilla/Mailer.pm b/Bugzilla/Mailer.pm
index d3810b72b..610523b8a 100644
--- a/Bugzilla/Mailer.pm
+++ b/Bugzilla/Mailer.pm
@@ -62,7 +62,20 @@ sub MessageToMTA {
return;
}
- my $email = ref($msg) ? $msg : Email::MIME->new($msg);
+ my $email;
+ if (ref $msg) {
+ $email = $msg;
+ }
+ else {
+ # RFC 2822 requires us to have CRLF for our line endings and
+ # Email::MIME doesn't do this for us. We use \015 (CR) and \012 (LF)
+ # directly because Perl translates "\n" depending on what platform
+ # you're running on. See http://perldoc.perl.org/perlport.html#Newlines
+ # We check for multiple CRs because of this Template-Toolkit bug:
+ # https://rt.cpan.org/Ticket/Display.html?id=43345
+ $msg =~ s/(?:\015+)?\012/\015\012/msg;
+ $email = new Email::MIME($msg);
+ }
# We add this header to uniquely identify all email that we
# send as coming from this Bugzilla installation.