public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Stoiko Ivanov <s.ivanov@proxmox.com>, pmg-devel@lists.proxmox.com
Subject: Re: [pmg-devel] [PATCH pmg-api 1/1] rulesystem: limit linelength of disclaimer to 998 bytes
Date: Tue, 23 Nov 2021 07:16:01 +0100	[thread overview]
Message-ID: <46367fc5-bd31-a8e3-1868-05a61e97278f@proxmox.com> (raw)
In-Reply-To: <20211122195010.359005-1-s.ivanov@proxmox.com>

On 22.11.21 20:50, Stoiko Ivanov wrote:
> As described in
> http://www.postfix.org/postconf.5.html#smtp_line_length_limit
> 
> postfix splits lines which are longer by inserting <cr><lf><space> to
> adhere with RFC 5322 (section 2.1.1):
> https://datatracker.ietf.org/doc/html/rfc5322#section-2.1.1
> 
> If a longer line is part of the disclaimer pmg-smtp-filter adds it
> without this modification, which breaks DKIM signatures (since the
> body is modified by postfix after the body hash is computed)
> 
> reported in our community forum:
> https://forum.proxmox.com/threads/dkim-body-has-been-altered-when-enabling-disclaimer-function.97919/
> 
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
>  src/PMG/RuleDB/Disclaimer.pm | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/PMG/RuleDB/Disclaimer.pm b/src/PMG/RuleDB/Disclaimer.pm
> index 1b1accf..1c81b03 100644
> --- a/src/PMG/RuleDB/Disclaimer.pm
> +++ b/src/PMG/RuleDB/Disclaimer.pm
> @@ -84,6 +84,10 @@ sub save {
>      defined($self->{ogroup}) || die "undefined object attribute: ERROR";
>      defined($self->{value}) || die "undefined object attribute: ERROR";
>  
> +    if ($self->{value} =~ /^.{998,}$/m) {


1. a comment that the regex match is used to avoid the fact that the `length` function is
   working on characters (vs. bytes) only would be good, but..

2. regex isn't actually _that_ better, if one adds a `use utf8` it also matches chars and
   not bytes here

Maybe go for the more explicit variant? I think the following should work (but with encodings
involved one is never sure..)

if (length(Encode::encode("UTF-8", $self->{value})) > 998)

> +	die "too long line in disclaimer - breaks RFC 5322!\n";
> +    }
> +
>      if (defined ($self->{id})) {
>  	# update
>  	
> 





      reply	other threads:[~2021-11-23  6:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-22 19:50 Stoiko Ivanov
2021-11-23  6:16 ` Thomas Lamprecht [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46367fc5-bd31-a8e3-1868-05a61e97278f@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    --cc=s.ivanov@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal