From: Hannes Laimer <h.laimer@proxmox.com>
To: Thomas Lamprecht <t.lamprecht@proxmox.com>, pmg-devel@lists.proxmox.com
Subject: Re: [pmg-devel] [PATCH pmg-api 1/3] pmgqm: add plain subject/from fields for reports
Date: Thu, 18 Sep 2025 16:08:25 +0200 [thread overview]
Message-ID: <c9aa47ad-16c1-4d03-9fda-ec4304ae3f1c@proxmox.com> (raw)
In-Reply-To: <fd202b15-b666-4c2b-91d6-ae718a185e32@proxmox.com>
On 18.09.25 15:21, Thomas Lamprecht wrote:
> Am 18.09.25 um 12:31 schrieb Hannes Laimer:
>> 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>
>> ---
>> src/PMG/CLI/pmgqm.pm | 17 +++++++++++++----
>> 1 file changed, 13 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/PMG/CLI/pmgqm.pm b/src/PMG/CLI/pmgqm.pm
>> index 41f9f1a..acac284 100755
>> --- a/src/PMG/CLI/pmgqm.pm
>> +++ b/src/PMG/CLI/pmgqm.pm
>> @@ -45,17 +45,26 @@ 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::decode_rfc1522($raw_subject);
>
> Not sure as I did not check in depth, but should the result from decode_rfc1522
> above also get encoded as UTF-8 to avoid issues with odd characters?
>
did some digging, and yes, that seems to be the problem.
```
# assume enc contains utf-8 and mime-encoded data returns a perl-string
(with wide characters)
sub decode_rfc1522 {
...
```
the template does not like getting `wide characters`, a
`Encode::encode('UTF-8', $plaintext)`
solves the problem. `rfc1522_to_html` already does basically this, and
`decode_rfc1522` does not. I'll fix that and send a v2.
Thanks for testing!
>>
>> - 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 $raw_sender = PVE::Tools::trim($head->get('sender'));
>> +
>> + my $from = PMG::Utils::rfc1522_to_html($raw_from);
>> + my $sender = PMG::Utils::rfc1522_to_html($raw_sender);
>> +
>> + my $from_plain = PMG::Utils::decode_rfc1522($raw_from);
>> + my $sender_plain = PMG::Utils::decode_rfc1522($raw_sender);
>
> same here I think.
>
>>
>> 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};
>
_______________________________________________
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-18 14:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-18 10:30 [pmg-devel] [PATCH pmg-api 0/3] adds plain-text variants for both reports Hannes Laimer
2025-09-18 10:30 ` [pmg-devel] [PATCH pmg-api 1/3] pmgqm: add plain subject/from fields for reports Hannes Laimer
2025-09-18 13:21 ` Thomas Lamprecht
2025-09-18 14:08 ` Hannes Laimer [this message]
2025-09-18 10:30 ` [pmg-devel] [PATCH pmg-api 2/3] fix #1621: templates: add plain-text variant of short/verbose spam report Hannes Laimer
2025-09-18 10:30 ` [pmg-devel] [PATCH pmg-api 3/3] fix #4023: templates: add plain-text variant of admin report Hannes Laimer
2025-09-18 14:33 ` [pmg-devel] superseded: [PATCH pmg-api 0/3] adds plain-text variants for both reports Hannes Laimer
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=c9aa47ad-16c1-4d03-9fda-ec4304ae3f1c@proxmox.com \
--to=h.laimer@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
--cc=t.lamprecht@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.