]> git.proxmox.com Git - pmg-api.git/commit
utils: fix mailflow if smtputf8 is disabled
authorStoiko Ivanov <s.ivanov@proxmox.com>
Wed, 21 Dec 2022 14:53:43 +0000 (15:53 +0100)
committerDominik Csapak <d.csapak@proxmox.com>
Fri, 23 Dec 2022 12:18:14 +0000 (13:18 +0100)
commit191e4709e99a5975fa66cf21847887566e108501
tree65fa46d7cf5b4f04009b89914cf4c833ff481997
parentf6b69037369e0ef77fd2eddb25e2c133b727bdab
utils: fix mailflow if smtputf8 is disabled

with the recent addition of smtputf8 support for the rulesystem setups
explicitly disabling smtputf8 in postfix got broken.

This is mostly noticeable for the spamreports (the receivers are taken
from the database and potentially decoded from utf-8, which sets the
'is_utf8' flag, and then tries to use the smtputf8 extension when
reinjecting the mail, which fails (since smtputf8 is disabled)

Instead of checking for the internal flag, we check for occurence of
characters which are not ascii printable (everything excluding
controlcharacters - '[\x20-\x7E]') in the envelope-addresses and
headers (there also for [\r\n\t], due to searching all headers and
folding). - see
https://perldoc.perl.org/perlunifaq#What-is-%22the-UTF8-flag%22?  and
https://perldoc.perl.org/perlrecharclass#POSIX-Character-Classes

The only diversion from the requirements in the smptutf8 rfc
https://www.rfc-editor.org/rfc/rfc6531
is that we do not check the headers of all parts of a multipart
message (think suggested filename for an attachment), but I assume
that this should not be an issue in mail-transit

the addresses now always get encoded as UTF-8, as this is robust for
aascii-only addresses.

reported in our community forum:
https://forum.proxmox.com/threads/.119387/

issue is reproducible by setting
`smtputf8_enable = no` in postfix main.cf
and sending a spamreport using `pmgqm`

regular mailflow should not be affected in those setups (as no utf-8
addresses would come into the system)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
src/PMG/Utils.pm