From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: Hannes Laimer <h.laimer@proxmox.com>
Cc: pmg-devel@lists.proxmox.com
Subject: Re: [pmg-devel] [PATCH pmg-api v3 1/3] pmgqm: add plain subject/from fields for reports
Date: Mon, 22 Sep 2025 13:54:48 +0200 [thread overview]
Message-ID: <20250922135448.333acb95@rosa.proxmox.com> (raw)
In-Reply-To: <20250919083622.22955-2-h.laimer@proxmox.com>
pmail would need a _plain variant as well:
When having mails in quarantine for:
`discard€@test.domain`
the rendered (plaint-text) report says:
`1 spam quarantine entries for discard€@test.domain`
On Fri, 19 Sep 2025 10:36:20 +0200
Hannes Laimer <h.laimer@proxmox.com> wrote:
> We don't want plain-text reports to contain HTML-escaped chars,
> this skips html encoding for the plain-text part.
>
> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> ---
> v3:
> - add small helper for 1522_decode+utf8_encode
>
> src/PMG/CLI/pmgqm.pm | 16 ++++++++++++----
> src/PMG/Utils.pm | 9 +++++++++
> 2 files changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/src/PMG/CLI/pmgqm.pm b/src/PMG/CLI/pmgqm.pm
> index 41f9f1a..0c30dbe 100755
> --- a/src/PMG/CLI/pmgqm.pm
> +++ b/src/PMG/CLI/pmgqm.pm
> @@ -45,17 +45,25 @@ sub get_item_data {
>
> $item->{id} = sprintf("C%dR%dT%d", $ref->{cid}, $ref->{rid}, $ref->{ticketid});
>
> - $item->{subject} =
> - PMG::Utils::rfc1522_to_html(PVE::Tools::trim($head->get('subject')) || 'No Subject');
> + my $raw_subject = PVE::Tools::trim($head->get('subject')) || 'No Subject';
> + $item->{subject} = PMG::Utils::rfc1522_to_html($raw_subject);
> + $item->{subject_plain} = PMG::Utils::rfc1522_to_plain_utf8($raw_subject);
>
> - my $from = PMG::Utils::rfc1522_to_html(PVE::Tools::trim($head->get('from') // $ref->{sender}));
> - my $sender = PMG::Utils::rfc1522_to_html(PVE::Tools::trim($head->get('sender')));
> + my $raw_from = PVE::Tools::trim($head->get('from') // $ref->{sender});
> + my $from = PMG::Utils::rfc1522_to_html($raw_from);
> + my $from_plain = PMG::Utils::rfc1522_to_plain_utf8($raw_from);
> +
> + my $raw_sender = PVE::Tools::trim($head->get('sender'));
> + my $sender = PMG::Utils::rfc1522_to_html($raw_sender);
> + my $sender_plain = PMG::Utils::rfc1522_to_plain_utf8($raw_sender);
>
> if ($sender) {
> $item->{sender} = $sender;
> $item->{from} = sprintf("%s on behalf of %s", $sender, $from);
> + $item->{from_plain} = sprintf("%s on behalf of %s", $sender_plain, $from_plain);
> } else {
> $item->{from} = $from;
> + $item->{from_plain} = $from_plain;
> }
>
> $item->{envelope_sender} = $ref->{sender};
> diff --git a/src/PMG/Utils.pm b/src/PMG/Utils.pm
> index 3dc909d..4e35aec 100644
> --- a/src/PMG/Utils.pm
> +++ b/src/PMG/Utils.pm
> @@ -1194,6 +1194,15 @@ sub decode_rfc1522 {
> return $res;
> }
>
> +sub rfc1522_to_plain_utf8 {
> + my ($enc) = @_;
> +
> + my $res = eval { Encode::encode('UTF-8', decode_rfc1522($enc)) };
> + return $enc if $@;
> +
> + return $res;
> +}
> +
> sub rfc1522_to_html {
> my ($enc) = @_;
>
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
next prev parent reply other threads:[~2025-09-22 11:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-19 8:36 [pmg-devel] [PATCH pmg-api v3 0/3] add plain-text variants for both reports Hannes Laimer
2025-09-19 8:36 ` [pmg-devel] [PATCH pmg-api v3 1/3] pmgqm: add plain subject/from fields for reports Hannes Laimer
2025-09-22 11:54 ` Stoiko Ivanov [this message]
2025-09-19 8:36 ` [pmg-devel] [PATCH pmg-api v3 2/3] fix #1621: templates: add plain-text variant of short/verbose spam report Hannes Laimer
2025-09-22 11:57 ` Stoiko Ivanov
2025-09-19 8:36 ` [pmg-devel] [PATCH pmg-api v3 3/3] fix #4023: templates: add plain-text variant of admin report Hannes Laimer
2025-09-22 11:47 ` Stoiko Ivanov
2025-09-22 14:29 ` [pmg-devel] applied: [PATCH pmg-api v3 0/3] add plain-text variants for both reports Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250922135448.333acb95@rosa.proxmox.com \
--to=s.ivanov@proxmox.com \
--cc=h.laimer@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox