From: mkanat%bugzilla.org <> Date: Sun, 22 Feb 2009 00:45:22 +0000 (+0000) Subject: Bug 467920: Remove multiple CRs in a row from the email template and make sure a X-Git-Tag: bugzilla-3.2.3~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcef1995f77ae132ad6a0550bc623c14ad31ba31;p=thirdparty%2Fbugzilla.git Bug 467920: Remove multiple CRs in a row from the email template and make sure a ll email lines end in CRLF. Patch By Max Kanat-Alexander r=glob, a=mkanat --- diff --git a/Bugzilla/Mailer.pm b/Bugzilla/Mailer.pm index 7b673440b0..645e65e4e0 100644 --- a/Bugzilla/Mailer.pm +++ b/Bugzilla/Mailer.pm @@ -56,7 +56,20 @@ sub MessageToMTA { my $method = Bugzilla->params->{'mail_delivery_method'}; return if $method eq 'None'; - 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 mark the mail as "auto-generated" and # thus to hopefully avoid auto replies.