public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Stoiko Ivanov <s.ivanov@proxmox.com>, pmg-devel@lists.proxmox.com
Subject: Re: [PATCH pmg-api 2/2] pmg-smtp-filter: log-headers: trim trailing whitespace
Date: Thu, 11 Jun 2026 11:09:46 +0200	[thread overview]
Message-ID: <abaff7d8-85f9-4c92-8ef3-2478f4846f26@proxmox.com> (raw)
In-Reply-To: <20260611085708.1121041-3-s.ivanov@proxmox.com>

depending on the subject, we could still have trailing space, e.g.

if the subject is the output of `perl -e 'print "x"x511; print " "; 
print "x";'`
the 512th character is space (but not the at the end pre cutting off)
so it gets printed with space as the last character.

one could argue that this is intended since we probably only
want to trim white space on the actual subject not what we log.

with that said:

Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>

On 6/11/26 10:56 AM, Stoiko Ivanov wrote:
> Reported-by: Dominik Csapak <d.csapak@proxmox.com>
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
>   src/bin/pmg-smtp-filter | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/src/bin/pmg-smtp-filter b/src/bin/pmg-smtp-filter
> index 7f9cdb85..7aa5865c 100755
> --- a/src/bin/pmg-smtp-filter
> +++ b/src/bin/pmg-smtp-filter
> @@ -714,6 +714,7 @@ sub handle_smtp {
>                   $value = PMG::Utils::decode_rfc1522($value);
>                   # remove non-printable and Unicode format chars to avoid log injection and spoofing
>                   $value =~ s/[^\p{XPosixPrint}]|\p{Cf}/ /g;
> +                $value =~ s/^\s+|\s+$//g;;
>                   return encode('UTF-8', substr($value, 0, 512));
>               };
>               # separate line on purpose, so the log-tracker does not parse it as an event





  reply	other threads:[~2026-06-11  9:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11  8:56 [PATCH pmg-api 0/2] small improvements for log-header functionality Stoiko Ivanov
2026-06-11  8:57 ` [PATCH pmg-api 1/2] config: add log-headers to pmg-smtp-filter parameters Stoiko Ivanov
2026-06-11  9:06   ` Dominik Csapak
2026-06-11  8:57 ` [PATCH pmg-api 2/2] pmg-smtp-filter: log-headers: trim trailing whitespace Stoiko Ivanov
2026-06-11  9:09   ` Dominik Csapak [this message]
2026-06-11 10:16 ` superseded: [PATCH pmg-api 0/2] small improvements for log-header functionality Stoiko Ivanov

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=abaff7d8-85f9-4c92-8ef3-2478f4846f26@proxmox.com \
    --to=d.csapak@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