[pmg-devel] [PATCH pmg-api v3 5/5] api: quarantine: decode addresses before delivery/userlisting
Stoiko Ivanov
s.ivanov at proxmox.com
Fri Mar 17 19:44:54 CET 2023
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 <d.csapak at proxomox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
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
More information about the pmg-devel
mailing list