From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id E91CBF434 for ; Thu, 15 Dec 2022 12:17:41 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BCBA768F5 for ; Thu, 15 Dec 2022 12:17:41 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 15 Dec 2022 12:17:39 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id AB18744A70 for ; Thu, 15 Dec 2022 12:17:39 +0100 (CET) Message-ID: <5acbd21d-ecf2-f96e-d2b6-4a956ed916dc@proxmox.com> Date: Thu, 15 Dec 2022 12:17:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Thunderbird/108.0 Content-Language: en-US To: pmg-devel@lists.proxmox.com References: <20221213170159.18049-1-s.ivanov@proxmox.com> From: Dominik Csapak In-Reply-To: <20221213170159.18049-1-s.ivanov@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.436 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_EVIL_NUMBERS4 1 Phone Numbers used by scammers NICE_REPLY_A -0.001 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com, rfc-editor.org, utils.pm, main.cf, perl.org] Subject: Re: [pmg-devel] [PATCH pmg-api] utils: fix mailflow if smtputf8 is disabled X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Dec 2022 11:17:42 -0000 the approach seems sensible, but theoretically it can lose the SMTPUTF8 information if neither sender nor recipients contain any non ascii characters and then it's not allowed to send utf8 headers according to rfc6531 section 3.2[0]: --- If the SMTPUTF8 SMTP extension is not offered by the SMTP server, the SMTPUTF8-aware SMTP client MUST NOT transmit an internationalized email address and MUST NOT transmit a mail message containing internationalized mail headers as described in RFC 6532 [RFC6532] at any level within its MIME structure [RFC2045]. --- also one comment inline 0: https://www.rfc-editor.org/rfc/rfc6531#section-3.2 On 12/13/22 18:01, Stoiko Ivanov wrote: > 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 explicitly check if the > address contains only ascii printable characters (everything excluding > controlcharacters - '[\x20-\x7E]') - see > https://perldoc.perl.org/perlunifaq#What-is-%22the-UTF8-flag%22? > and > https://perldoc.perl.org/perlrecharclass#POSIX-Character-Classes > > 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 > --- > src/PMG/Utils.pm | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/src/PMG/Utils.pm b/src/PMG/Utils.pm > index 10193f6..b0a3c52 100644 > --- a/src/PMG/Utils.pm > +++ b/src/PMG/Utils.pm > @@ -247,7 +247,7 @@ sub reinject_mail { > > my $has_utf8_targets = 0; > foreach my $target (@$targets) { > - if (utf8::is_utf8($target)) { > + if ($target =~ /[^\p{PosixPrint}]/) { > $has_utf8_targets = 1; > last; > } > @@ -255,7 +255,7 @@ sub reinject_mail { > > my $mail_opts = " BODY=8BITMIME"; > my $sender_addr; > - if (utf8::is_utf8($sender)) { > + if ($sender =~ /[^\p{PosixPrint}]/) { > $sender_addr = encode('UTF-8', $smtp->_addr($sender)); > $mail_opts .= " SMTPUTF8"; > } else { > @@ -285,7 +285,7 @@ sub reinject_mail { > } > } > > - if (utf8::is_utf8($target)) { > + if ($sender =~ /[^\p{PosixPrint}]/) { > $rcpt_addr = encode('UTF-8', $smtp->_addr($target)); probably c&p error, is_utf8($target) becomes $sender =~ > } else { > $rcpt_addr = $smtp->_addr($target);