summaryrefslogtreecommitdiff
path: root/mail/spamass-milter/files/patch-spamass-milter.cpp
blob: cc0a0e902c3f8c5d6b7d9d05e38f49dd499f2042 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
--- spamass-milter.cpp
+++ spamass-milter.cpp
@@ -1206,7 +1206,23 @@ mlfi_header(SMFICTX* ctx, char* headerf,
     assassin->set_subject(headerv);
 
   // assemble header to be written to SpamAssassin
-  string header = string(headerf) + ": " + headerv + "\r\n";
+  string header = headerv;
+
+  // Replace all LF with CRLF
+  // As milter documentation says:
+  //     headerv    Header field value.  The content of the header may
+  //       include folded white space, i.e., multiple lines with following
+  //       white space where lines are separated by LF (not CR/LF).  The
+  //       trailing line terminator (CR/LF) is removed.
+  // Need to make sure folded header line breaks are sent to SA as CRLF
+  string::size_type idx = header.size();
+  while ( (idx = header.rfind("\n", idx)) != string::npos )
+  {
+     header.replace(idx,1,"\r\n");
+  }
+
+  // final assembly
+  header = string(headerf) + ": " + header + "\r\n";
  
   try {
     // write to SpamAssassin client