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 66ABEB815 for ; Thu, 24 Nov 2022 13:21:25 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6FE762F174 for ; Thu, 24 Nov 2022 13:21:24 +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, 24 Nov 2022 13:21:21 +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 4F1D143A11 for ; Thu, 24 Nov 2022 13:21:15 +0100 (CET) From: Dominik Csapak To: pmg-devel@lists.proxmox.com Date: Thu, 24 Nov 2022 13:21:09 +0100 Message-Id: <20221124122112.666868-10-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221124122112.666868-1-d.csapak@proxmox.com> References: <20221124122112.666868-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.064 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 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. [utils.pm, quarantine.pm] Subject: [pmg-devel] [PATCH pmg-api v4 09/12] quarantine: fix adding non-ascii senders to wl/bl 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, 24 Nov 2022 12:21:25 -0000 by trying to decode them since they maybe were sent with SMTPUTF8 also make 'try_decode_utf8' an export of Utils and use that Signed-off-by: Dominik Csapak --- src/PMG/API2/Quarantine.pm | 8 ++++---- src/PMG/Utils.pm | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/PMG/API2/Quarantine.pm b/src/PMG/API2/Quarantine.pm index 819c78c..f9e3e3d 100644 --- a/src/PMG/API2/Quarantine.pm +++ b/src/PMG/API2/Quarantine.pm @@ -24,7 +24,7 @@ use PVE::RESTHandler; use PVE::INotify; use PVE::APIServer::Formatter; -use PMG::Utils; +use PMG::Utils qw(try_decode_utf8); use PMG::AccessControl; use PMG::Config; use PMG::DBTools; @@ -141,8 +141,8 @@ my $parse_header_info = sub { my $sender = PMG::Utils::decode_rfc1522(PVE::Tools::trim($head->get('sender'))); $res->{sender} = $sender if $sender && ($sender ne $res->{from}); - $res->{envelope_sender} = PMG::Utils::try_decode_utf8($ref->{sender}); - $res->{receiver} = PMG::Utils::try_decode_utf8($ref->{receiver} // $ref->{pmail}); + $res->{envelope_sender} = try_decode_utf8($ref->{sender}); + $res->{receiver} = try_decode_utf8($ref->{receiver} // $ref->{pmail}); $res->{id} = 'C' . $ref->{cid} . 'R' . $ref->{rid} . 'T' . $ref->{ticketid}; $res->{time} = $ref->{time}; $res->{bytes} = $ref->{bytes}; @@ -1164,7 +1164,7 @@ __PACKAGE__->register_method ({ for my $id (@idlist) { my $ref = $get_and_check_mail->($id, $rpcenv, $dbh); - my $sender = $get_real_sender->($ref); + my $sender = try_decode_utf8($get_real_sender->($ref)); if ($action eq 'whitelist') { PMG::Quarantine::add_to_blackwhite($dbh, $ref->{pmail}, 'WL', [ $sender ]); diff --git a/src/PMG/Utils.pm b/src/PMG/Utils.pm index 5c9e873..463de6d 100644 --- a/src/PMG/Utils.pm +++ b/src/PMG/Utils.pm @@ -45,6 +45,7 @@ use base 'Exporter'; our @EXPORT_OK = qw( postgres_admin_cmd +try_decode_utf8 ); my $valid_pmg_realms = ['pam', 'pmg', 'quarantine']; -- 2.30.2