]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 467920: Remove multiple CRs in a row from the email template and make sure all...
authormkanat%bugzilla.org <>
Sun, 22 Feb 2009 00:44:25 +0000 (00:44 +0000)
committermkanat%bugzilla.org <>
Sun, 22 Feb 2009 00:44:25 +0000 (00:44 +0000)
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=glob, a=mkanat

Bugzilla/Mailer.pm

index d3810b72bcae4b9d331d31c8e6899155a9793860..610523b8a7e9b2dadf043a6c9161a02798b98a8b 100644 (file)
@@ -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.