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 CA92091555 for ; Fri, 17 Mar 2023 19:45:49 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id ADE341D19B for ; Fri, 17 Mar 2023 19:45:19 +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 ; Fri, 17 Mar 2023 19:45:18 +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 431974520E for ; Fri, 17 Mar 2023 19:45:17 +0100 (CET) From: Stoiko Ivanov To: pmg-devel@lists.proxmox.com Date: Fri, 17 Mar 2023 19:44:54 +0100 Message-Id: <20230317184456.26465-6-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230317184456.26465-1-s.ivanov@proxmox.com> References: <20230317184456.26465-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.142 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. [quarantine.pm] Subject: [pmg-devel] [PATCH pmg-api v3 5/5] api: quarantine: decode addresses before delivery/userlisting 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: Fri, 17 Mar 2023 18:45:49 -0000 With the change of using reinject_local_mail for the quarantine delivery the issue of not properly decoding the entries we get from the database before delivering became apparent The database returns utf-8 encoded strings, reinject_local_mail and add_to_blackwhite expects perl-strings (with wide characters) and encodes them (a second time) - this patch decodes the database strings before passing it on. add_to_black_white is used in a few API calls (via read_or_modify_user_bw_list), therefore the approach of decode (from database), and encode (for database) was chosen. Reported-by: Dominik Csapak Signed-off-by: Stoiko Ivanov --- src/PMG/API2/Quarantine.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/PMG/API2/Quarantine.pm b/src/PMG/API2/Quarantine.pm index 6318082..7101795 100644 --- a/src/PMG/API2/Quarantine.pm +++ b/src/PMG/API2/Quarantine.pm @@ -1182,15 +1182,17 @@ __PACKAGE__->register_method ({ my $ref = $get_and_check_mail->($id, $rpcenv, $dbh); my $sender = try_decode_utf8($get_real_sender->($ref)); + my $pmail = try_decode_utf8($ref->{pmail}); + my $receiver = try_decode_utf8($ref->{receiver} // $ref->{pmail}); if ($action eq 'whitelist') { - PMG::Quarantine::add_to_blackwhite($dbh, $ref->{pmail}, 'WL', [ $sender ]); - PMG::Quarantine::deliver_quarantined_mail($dbh, $ref, $ref->{receiver} // $ref->{pmail}); + PMG::Quarantine::add_to_blackwhite($dbh, $pmail, 'WL', [ $sender ]); + PMG::Quarantine::deliver_quarantined_mail($dbh, $ref, $receiver); } elsif ($action eq 'blacklist') { - PMG::Quarantine::add_to_blackwhite($dbh, $ref->{pmail}, 'BL', [ $sender ]); + PMG::Quarantine::add_to_blackwhite($dbh, $pmail, 'BL', [ $sender ]); PMG::Quarantine::delete_quarantined_mail($dbh, $ref); } elsif ($action eq 'deliver') { - PMG::Quarantine::deliver_quarantined_mail($dbh, $ref, $ref->{receiver} // $ref->{pmail}); + PMG::Quarantine::deliver_quarantined_mail($dbh, $ref, $receiver); } elsif ($action eq 'delete') { PMG::Quarantine::delete_quarantined_mail($dbh, $ref); } else { -- 2.30.2