Patch: Fix header wrap character error

Patrick Ben Koetter p at sys4.de
Wed Jul 11 21:28:51 CEST 2018


The attached patch fixes a header wrap problem. Amavis would, regardless of
the wrap char used in the original mail, always use a TAB to indent the long
header lines. This would break DKIM signatures.

The patch makes the behaviour configurable.

p at rick


-- 
[*] sys4 AG
 
https://sys4.de, +49 (89) 30 90 46 64
Schleißheimer Straße 26/MG,80333 München
 
Sitz der Gesellschaft: München, Amtsgericht München: HRB 199263
Vorstand: Patrick Ben Koetter, Marc Schiffbauer, Wolfgang Stief
Aufsichtsratsvorsitzender: Florian Kirstein
 
-------------- next part --------------
--- amavisd-new-2.11.0/amavisd	2016-04-26 21:24:33.000000000 +0200
+++ amavis-patched/amavisd	2018-07-11 16:30:52.288441070 +0200
@@ -382,6 +382,7 @@
       $DEBUG %i_know_what_i_am_doing
       $do_syslog $logfile $allow_preserving_evidence $enable_log_capture
       $log_short_templ $log_verbose_templ $logline_maxlen
+      $default_wrap_char
       $nanny_details_level $max_servers $max_requests
       $min_servers $min_spare_servers $max_spare_servers
       %current_policy_bank %policy_bank %interface_policy
@@ -760,6 +761,9 @@
   # to avoid syslog truncating lines; see sub write_log
   $logline_maxlen = 980;
 
+  # make default wrap char in function hdr configurable
+  $default_wrap_char = "\t"; # use undef for RFC-complient behaviour
+
   $nanny_details_level = 1;  # register_proc verbosity: 0, 1, 2
 
 # $inner_sock_specs in amavis-services should match one of the sockets
@@ -9238,7 +9242,7 @@
   $VERSION = '2.412';
   @ISA = qw(Exporter);
   @EXPORT_OK = qw(&hdr);
-  import Amavis::Conf qw(:platform c cr ca);
+  import Amavis::Conf qw(:platform c cr ca $default_wrap_char);
   import Amavis::Timing qw(section_time);
   import Amavis::rfc2821_2822_Tools qw(wrap_string);
   import Amavis::Util qw(ll do_log min max q_encode
@@ -9340,7 +9344,7 @@
 #
 sub hdr {
   my($field_name, $field_body, $structured, $wrap_char, $smtputf8) = @_;
-  $wrap_char = "\t"  if !defined $wrap_char;
+  $wrap_char = $default_wrap_char  if !defined $wrap_char;
   safe_encode_utf8_inplace($field_name);  # to octets (if not already)
   $field_name =~ tr/\x21-\x39\x3B-\x7E/?/c;  # printable ASCII except ':'
   my $field_body_is_utf8 = utf8::is_utf8($field_body);
@@ -9393,7 +9397,7 @@
     $str =~ s/\n(?=[ \t]*(\n|\z))//g;   # whitespace lines within or at end
     $str =~ s/\n(?![ \t])/\n /g;  # insert a space at line folds if missing
   } else {
-    $wrap_char = "\t"  if !defined $wrap_char;
+    $wrap_char = $default_wrap_char  if !defined $wrap_char;
     $str = wrap_string($str, 78, '', $wrap_char, $structured
                       )  if $structured==1 || length($str) > 78;
   }


More information about the amavis-users mailing list