]> git.donarmstrong.com Git - deb_pkgs/spamass-milter.git/commitdiff
Use CRLF in folded headers instead of LF (closes: #1031417). master
authorDon Armstrong <don@donarmstrong.com>
Sun, 16 Mar 2025 23:00:37 +0000 (16:00 -0700)
committerDon Armstrong <don@donarmstrong.com>
Sun, 16 Mar 2025 23:00:37 +0000 (16:00 -0700)
Thanks to Matthieu Schapranow for the patch.

debian/patches/crlf_in_generated_header [new file with mode: 0644]
debian/patches/series

diff --git a/debian/patches/crlf_in_generated_header b/debian/patches/crlf_in_generated_header
new file mode 100644 (file)
index 0000000..b1a8d15
--- /dev/null
@@ -0,0 +1,34 @@
+Description: Spamass-milter doesn't properly maintain CRLF in folded header newlines.
+Origin: https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7785
+Bug: #7785
+Author: Henrik Krohns, Matthieu Schapranow <schapranow@hpi.de<mailto:schapranow@hpi.de>, Don Armstrong <don@debian.org>
+Forwarded: no
+--- a/spamass-milter.cpp
++++ b/spamass-milter.cpp
+@@ -1135,7 +1135,25 @@
+     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 )
++  {
++    if (idx > 0 && header[idx-1] != '\r') { 
++      header.replace(idx,1,"\r\n");
++    }
++  }
++
++  // final assembly
++  header = string(headerf) + ": " + header + "\r\n";
+  
+   try {
+     // write to SpamAssassin client
index 39873738b0bc23b38c8f1319bb69140c4c8fc7c0..b035f046ebbd9e71f1b173fbd31000aa0b2012b8 100644 (file)
@@ -3,3 +3,4 @@ fix_spacing_in_received_header
 auth_in_received
 queueid_in_envrcpt
 update_for_new_autoconf
+crlf_in_generated_header