public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH pmg-api v2 0/3] add plain-text variants for both reports
@ 2025-09-18 14:31 Hannes Laimer
  2025-09-18 14:31 ` [pmg-devel] [PATCH pmg-api v2 1/3] pmgqm: add plain subject/from fields for reports Hannes Laimer
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Hannes Laimer @ 2025-09-18 14:31 UTC (permalink / raw)
  To: pmg-devel

This addresses both #1621 and #4023.

https://bugzilla.proxmox.com/show_bug.cgi?id=4023
https://bugzilla.proxmox.com/show_bug.cgi?id=1621

v2, thanks @Thomas:
 - UTF-8 encode plain-text subject/sender/from before using in templates
 - remove `subject:` line from plain template, this is not needed in that
   part of the mail

Hannes Laimer (3):
  pmgqm: add plain subject/from fields for reports
  fix #1621: templates: add plain-text variant of short/verbose spam
    report
  fix #4023: templates: add plain-text variant of admin report

 src/Makefile                              |  3 ++
 src/PMG/CLI/pmgqm.pm                      | 16 ++++++--
 src/templates/pmgreport.plain.tt          | 50 +++++++++++++++++++++++
 src/templates/spamreport-short.plain.tt   |  9 ++++
 src/templates/spamreport-verbose.plain.tt | 18 ++++++++
 5 files changed, 92 insertions(+), 4 deletions(-)
 create mode 100644 src/templates/pmgreport.plain.tt
 create mode 100644 src/templates/spamreport-short.plain.tt
 create mode 100644 src/templates/spamreport-verbose.plain.tt

-- 
2.47.3



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [pmg-devel] [PATCH pmg-api v2 1/3] pmgqm: add plain subject/from fields for reports
  2025-09-18 14:31 [pmg-devel] [PATCH pmg-api v2 0/3] add plain-text variants for both reports Hannes Laimer
@ 2025-09-18 14:31 ` Hannes Laimer
  2025-09-18 14:54   ` Thomas Lamprecht
  2025-09-18 14:31 ` [pmg-devel] [PATCH pmg-api v2 2/3] fix #1621: templates: add plain-text variant of short/verbose spam report Hannes Laimer
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Hannes Laimer @ 2025-09-18 14:31 UTC (permalink / raw)
  To: pmg-devel

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>
---
v2:
- explicitly utf8 encode after `decode_rfc1522`

 src/PMG/CLI/pmgqm.pm | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/PMG/CLI/pmgqm.pm b/src/PMG/CLI/pmgqm.pm
index 41f9f1a..c26b545 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} = Encode::encode('UTF-8', PMG::Utils::decode_rfc1522($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 = Encode::encode('UTF-8', PMG::Utils::decode_rfc1522($raw_from));
+
+    my $raw_sender = PVE::Tools::trim($head->get('sender'));
+    my $sender = PMG::Utils::rfc1522_to_html($raw_sender);
+    my $sender_plain = Encode::encode('UTF-8', PMG::Utils::decode_rfc1522($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};
-- 
2.47.3



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [pmg-devel] [PATCH pmg-api v2 2/3] fix #1621: templates: add plain-text variant of short/verbose spam report
  2025-09-18 14:31 [pmg-devel] [PATCH pmg-api v2 0/3] add plain-text variants for both reports Hannes Laimer
  2025-09-18 14:31 ` [pmg-devel] [PATCH pmg-api v2 1/3] pmgqm: add plain subject/from fields for reports Hannes Laimer
@ 2025-09-18 14:31 ` Hannes Laimer
  2025-09-18 15:06   ` Thomas Lamprecht
  2025-09-18 14:31 ` [pmg-devel] [PATCH pmg-api v2 3/3] fix #4023: templates: add plain-text variant of admin report Hannes Laimer
  2025-09-19  8:37 ` [pmg-devel] superseded: [PATCH pmg-api v2 0/3] add plain-text variants for both reports Hannes Laimer
  3 siblings, 1 reply; 13+ messages in thread
From: Hannes Laimer @ 2025-09-18 14:31 UTC (permalink / raw)
  To: pmg-devel

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
v2:
- drop `subject:` line

 src/Makefile                              |  2 ++
 src/templates/spamreport-short.plain.tt   |  9 +++++++++
 src/templates/spamreport-verbose.plain.tt | 18 ++++++++++++++++++
 3 files changed, 29 insertions(+)
 create mode 100644 src/templates/spamreport-short.plain.tt
 create mode 100644 src/templates/spamreport-verbose.plain.tt

diff --git a/src/Makefile b/src/Makefile
index 896319b..b75c818 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -27,7 +27,9 @@ TEMPLATES =				\
 	fetchmailrc.tt			\
 	pmgreport.tt			\
 	spamreport-verbose.tt		\
+	spamreport-verbose.plain.tt	\
 	spamreport-short.tt		\
+	spamreport-short.plain.tt	\
 	main.cf.in			\
 	main.cf.in.demo			\
 	master.cf.in			\
diff --git a/src/templates/spamreport-short.plain.tt b/src/templates/spamreport-short.plain.tt
new file mode 100644
index 0000000..2c13431
--- /dev/null
+++ b/src/templates/spamreport-short.plain.tt
@@ -0,0 +1,9 @@
+You received [% mailcount %] spam mail(s).
+
+[% SET links = [] %]
+Manage your spam quarantine: [% n = links.size + 1; links.push(managehref); %][[% n %]]
+Powered by Proxmox: [% n = links.size + 1; links.push('http://www.proxmox.com'); %][[% n %]]
+
+Links:
+[% FOREACH l IN links %][% loop.index + 1 %]: [% l %]
+[% END %]
diff --git a/src/templates/spamreport-verbose.plain.tt b/src/templates/spamreport-verbose.plain.tt
new file mode 100644
index 0000000..1a0c182
--- /dev/null
+++ b/src/templates/spamreport-verbose.plain.tt
@@ -0,0 +1,18 @@
+[% SET links = [] -%]
+[% IF items.size -%]
+Spam quarantine entries for [% pmail %]:
+
+[% FOREACH item IN items %]
+- [% item.date %] [% item.time %] From: [% item.from_plain %]
+  Subject: [% item.subject_plain %] [% n = links.size + 1; links.push(item.href); %][[% n %]]
+
+[% END %]
+[% ELSE %]
+No spam entries for the selected period.
+[% END %]
+Manage your spam quarantine: [% n = links.size + 1; links.push(managehref); %][[% n %]]
+Powered by Proxmox: [% n = links.size + 1; links.push('http://www.proxmox.com'); %][[% n %]]
+
+Links:
+[% FOREACH l IN links %][% loop.index + 1 %]: [% l %]
+[% END %]
-- 
2.47.3



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [pmg-devel] [PATCH pmg-api v2 3/3] fix #4023: templates: add plain-text variant of admin report
  2025-09-18 14:31 [pmg-devel] [PATCH pmg-api v2 0/3] add plain-text variants for both reports Hannes Laimer
  2025-09-18 14:31 ` [pmg-devel] [PATCH pmg-api v2 1/3] pmgqm: add plain subject/from fields for reports Hannes Laimer
  2025-09-18 14:31 ` [pmg-devel] [PATCH pmg-api v2 2/3] fix #1621: templates: add plain-text variant of short/verbose spam report Hannes Laimer
@ 2025-09-18 14:31 ` Hannes Laimer
  2025-09-18 22:26   ` Stoiko Ivanov
  2025-09-19  8:37 ` [pmg-devel] superseded: [PATCH pmg-api v2 0/3] add plain-text variants for both reports Hannes Laimer
  3 siblings, 1 reply; 13+ messages in thread
From: Hannes Laimer @ 2025-09-18 14:31 UTC (permalink / raw)
  To: pmg-devel

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
v2:
- drop `subject:` line

 src/Makefile                     |  1 +
 src/templates/pmgreport.plain.tt | 50 ++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)
 create mode 100644 src/templates/pmgreport.plain.tt

diff --git a/src/Makefile b/src/Makefile
index b75c818..2c5ef28 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -26,6 +26,7 @@ CONF_MANS= pmg.conf.5 cluster.conf.5
 TEMPLATES =				\
 	fetchmailrc.tt			\
 	pmgreport.tt			\
+	pmgreport.plain.tt		\
 	spamreport-verbose.tt		\
 	spamreport-verbose.plain.tt	\
 	spamreport-short.tt		\
diff --git a/src/templates/pmgreport.plain.tt b/src/templates/pmgreport.plain.tt
new file mode 100644
index 0000000..18871b2
--- /dev/null
+++ b/src/templates/pmgreport.plain.tt
@@ -0,0 +1,50 @@
+[% IF cluster -%]
+Cluster Status
+[% FOREACH item IN cluster -%]
+- Hostname: [% item.hostname %]
+  IP Address: [% item.ip %]
+  Role: [% item.type %]
+  State: [% item.state %]
+  Load: [% item.loadavg1 %]
+  Memory: [% item.memory %]
+  Disk: [% item.disk %]
+[% IF !loop.last %]----
+[% END %]
+[% END %]
+[% END %]
+[% IF system -%]
+System Status
+[% FOREACH item IN system -%]
+- [% item.text %]: [% item.value %]
+[% END %]
+[% END %]
+[% IF incoming -%]
+Incoming Mails (24 hours)
+[% FOREACH item IN incoming -%]
+- [% item.text %][% IF item.percentage.defined %] ([% item.percentage %]%)[% END %]: [% item.value %]
+[% END %]
+[% END %]
+[% IF outgoing -%]
+Outgoing Mails (24 hours)
+[% FOREACH item IN outgoing -%]
+- [% item.text %][% IF item.percentage.defined %] ([% item.percentage %]%)[% END %]: [% item.value %]
+[% END %]
+[% END %]
+[% IF virusstat -%]
+Virus Charts (Top 10)
+[% FOREACH item IN virusstat -%]
+- [% item.name %]: [% item.count %]
+[% END %]
+[% END %]
+[% IF virusquar -%]
+Virus Quarantine
+[% FOREACH item IN virusquar -%]
+- [% item.text %]: [% item.value %]
+[% END %]
+[% END %]
+[% IF spamquar -%]
+Spam Quarantine
+[% FOREACH item IN spamquar -%]
+- [% item.text %]: [% item.value %]
+[% END %]
+[% END %]
-- 
2.47.3



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [pmg-devel] [PATCH pmg-api v2 1/3] pmgqm: add plain subject/from fields for reports
  2025-09-18 14:31 ` [pmg-devel] [PATCH pmg-api v2 1/3] pmgqm: add plain subject/from fields for reports Hannes Laimer
@ 2025-09-18 14:54   ` Thomas Lamprecht
  2025-09-18 23:21     ` Stoiko Ivanov
  0 siblings, 1 reply; 13+ messages in thread
From: Thomas Lamprecht @ 2025-09-18 14:54 UTC (permalink / raw)
  To: Hannes Laimer, pmg-devel

Am 18.09.25 um 16:32 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>
> ---
> v2:
> - explicitly utf8 encode after `decode_rfc1522`
> 
>  src/PMG/CLI/pmgqm.pm | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/src/PMG/CLI/pmgqm.pm b/src/PMG/CLI/pmgqm.pm
> index 41f9f1a..c26b545 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} = Encode::encode('UTF-8', PMG::Utils::decode_rfc1522($raw_subject));

it's a bit borderline, but might be worth adding a rfc1522_to_utf8 (or
rfc1522_to_plain_utf8?) helper for this. For one there would be a tiny
bit better code re-use, but it would make it slightly clearer for what
happens here.

>  
> -    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 = Encode::encode('UTF-8', PMG::Utils::decode_rfc1522($raw_from));
> +
> +    my $raw_sender = PVE::Tools::trim($head->get('sender'));
> +    my $sender = PMG::Utils::rfc1522_to_html($raw_sender);
> +    my $sender_plain = Encode::encode('UTF-8', PMG::Utils::decode_rfc1522($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};



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [pmg-devel] [PATCH pmg-api v2 2/3] fix #1621: templates: add plain-text variant of short/verbose spam report
  2025-09-18 14:31 ` [pmg-devel] [PATCH pmg-api v2 2/3] fix #1621: templates: add plain-text variant of short/verbose spam report Hannes Laimer
@ 2025-09-18 15:06   ` Thomas Lamprecht
  2025-09-18 23:26     ` Stoiko Ivanov
  0 siblings, 1 reply; 13+ messages in thread
From: Thomas Lamprecht @ 2025-09-18 15:06 UTC (permalink / raw)
  To: Hannes Laimer, pmg-devel

Am 18.09.25 um 16:32 schrieb Hannes Laimer:
> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> ---
> v2:
> - drop `subject:` line
> 
>  src/Makefile                              |  2 ++
>  src/templates/spamreport-short.plain.tt   |  9 +++++++++
>  src/templates/spamreport-verbose.plain.tt | 18 ++++++++++++++++++
>  3 files changed, 29 insertions(+)
>  create mode 100644 src/templates/spamreport-short.plain.tt
>  create mode 100644 src/templates/spamreport-verbose.plain.tt
> 
> diff --git a/src/Makefile b/src/Makefile
> index 896319b..b75c818 100644
> --- a/src/Makefile
> +++ b/src/Makefile
> @@ -27,7 +27,9 @@ TEMPLATES =				\
>  	fetchmailrc.tt			\
>  	pmgreport.tt			\
>  	spamreport-verbose.tt		\
> +	spamreport-verbose.plain.tt	\
>  	spamreport-short.tt		\
> +	spamreport-short.plain.tt	\
>  	main.cf.in			\
>  	main.cf.in.demo			\
>  	master.cf.in			\
> diff --git a/src/templates/spamreport-short.plain.tt b/src/templates/spamreport-short.plain.tt
> new file mode 100644
> index 0000000..2c13431
> --- /dev/null
> +++ b/src/templates/spamreport-short.plain.tt
> @@ -0,0 +1,9 @@
> +You received [% mailcount %] spam mail(s).
> +
> +[% SET links = [] %]
> +Manage your spam quarantine: [% n = links.size + 1; links.push(managehref); %][[% n %]]
> +Powered by Proxmox: [% n = links.size + 1; links.push('http://www.proxmox.com'); %][[% n %]]
> +
> +Links:
> +[% FOREACH l IN links %][% loop.index + 1 %]: [% l %]
> +[% END %]
> diff --git a/src/templates/spamreport-verbose.plain.tt b/src/templates/spamreport-verbose.plain.tt
> new file mode 100644
> index 0000000..1a0c182
> --- /dev/null
> +++ b/src/templates/spamreport-verbose.plain.tt
> @@ -0,0 +1,18 @@
> +[% SET links = [] -%]
> +[% IF items.size -%]
> +Spam quarantine entries for [% pmail %]:
> +
> +[% FOREACH item IN items %]
> +- [% item.date %] [% item.time %] From: [% item.from_plain %]
> +  Subject: [% item.subject_plain %] [% n = links.size + 1; links.push(item.href); %][[% n %]]
> +
> +[% END %]
> +[% ELSE %]
> +No spam entries for the selected period.
> +[% END %]
> +Manage your spam quarantine: [% n = links.size + 1; links.push(managehref); %][[% n %]]
> +Powered by Proxmox: [% n = links.size + 1; links.push('http://www.proxmox.com'); %][[% n %]]
> +
> +Links:
> +[% FOREACH l IN links %][% loop.index + 1 %]: [% l %]

Not sure about the reference like link lists at the bottom, if there's more than a
handful of mails in the quarantine it gets quite hard to navigate fast, albeit
searching for the reference number naturally is an option..

Maybe put at least the general link to the web UI at the top? That might be a good
compromise where I do not have to scroll.

I.e., move "Manage your spam quarantine" up and inline the link for that and probably
also to www.proxmox.com as it's very short compared to the quarantine UI links anyway
and not much is gained by placing it as reference link (and do s/http/https/ for that)

Would like to hear some other opinions here (CC'in Fabian, as he is a big plain
text mail user too, but others are naturally welcome to chime in too).

> +[% END %]



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [pmg-devel] [PATCH pmg-api v2 3/3] fix #4023: templates: add plain-text variant of admin report
  2025-09-18 14:31 ` [pmg-devel] [PATCH pmg-api v2 3/3] fix #4023: templates: add plain-text variant of admin report Hannes Laimer
@ 2025-09-18 22:26   ` Stoiko Ivanov
  0 siblings, 0 replies; 13+ messages in thread
From: Stoiko Ivanov @ 2025-09-18 22:26 UTC (permalink / raw)
  To: Hannes Laimer; +Cc: pmg-devel

Thanks for tackling this so quickly!

On Thu, 18 Sep 2025 16:31:42 +0200
Hannes Laimer <h.laimer@proxmox.com> wrote:

> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> ---
> v2:
> - drop `subject:` line
why did you change this?
the subject should get stripped out and is not present in resulting report.
not having it in place causes `pmgreport` to fail, if you try to remove
the text/html part (via `touch /etc/pmg/templates/pmgreport.tt`)
But checking this I realized that the docs were a bit tight-lipped on this
functionality (and had a factual error):
https://git.proxmox.com/?p=pmg-docs.git;a=commitdiff;h=78ac287f22dca4856f8304deb8b88dd0303fdb53

else the plain-text report looks fine!



> 
>  src/Makefile                     |  1 +
>  src/templates/pmgreport.plain.tt | 50 ++++++++++++++++++++++++++++++++
>  2 files changed, 51 insertions(+)
>  create mode 100644 src/templates/pmgreport.plain.tt
> 
> diff --git a/src/Makefile b/src/Makefile
> index b75c818..2c5ef28 100644
> --- a/src/Makefile
> +++ b/src/Makefile
> @@ -26,6 +26,7 @@ CONF_MANS= pmg.conf.5 cluster.conf.5
>  TEMPLATES =				\
>  	fetchmailrc.tt			\
>  	pmgreport.tt			\
> +	pmgreport.plain.tt		\
>  	spamreport-verbose.tt		\
>  	spamreport-verbose.plain.tt	\
>  	spamreport-short.tt		\
> diff --git a/src/templates/pmgreport.plain.tt b/src/templates/pmgreport.plain.tt
> new file mode 100644
> index 0000000..18871b2
> --- /dev/null
> +++ b/src/templates/pmgreport.plain.tt
> @@ -0,0 +1,50 @@
> +[% IF cluster -%]
> +Cluster Status
> +[% FOREACH item IN cluster -%]
> +- Hostname: [% item.hostname %]
> +  IP Address: [% item.ip %]
> +  Role: [% item.type %]
> +  State: [% item.state %]
> +  Load: [% item.loadavg1 %]
> +  Memory: [% item.memory %]
> +  Disk: [% item.disk %]
> +[% IF !loop.last %]----
> +[% END %]
> +[% END %]
> +[% END %]
> +[% IF system -%]
> +System Status
> +[% FOREACH item IN system -%]
> +- [% item.text %]: [% item.value %]
> +[% END %]
> +[% END %]
> +[% IF incoming -%]
> +Incoming Mails (24 hours)
> +[% FOREACH item IN incoming -%]
> +- [% item.text %][% IF item.percentage.defined %] ([% item.percentage %]%)[% END %]: [% item.value %]
> +[% END %]
> +[% END %]
> +[% IF outgoing -%]
> +Outgoing Mails (24 hours)
> +[% FOREACH item IN outgoing -%]
> +- [% item.text %][% IF item.percentage.defined %] ([% item.percentage %]%)[% END %]: [% item.value %]
> +[% END %]
> +[% END %]
> +[% IF virusstat -%]
> +Virus Charts (Top 10)
> +[% FOREACH item IN virusstat -%]
> +- [% item.name %]: [% item.count %]
> +[% END %]
> +[% END %]
> +[% IF virusquar -%]
> +Virus Quarantine
> +[% FOREACH item IN virusquar -%]
> +- [% item.text %]: [% item.value %]
> +[% END %]
> +[% END %]
> +[% IF spamquar -%]
> +Spam Quarantine
> +[% FOREACH item IN spamquar -%]
> +- [% item.text %]: [% item.value %]
> +[% END %]
> +[% END %]



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [pmg-devel] [PATCH pmg-api v2 1/3] pmgqm: add plain subject/from fields for reports
  2025-09-18 14:54   ` Thomas Lamprecht
@ 2025-09-18 23:21     ` Stoiko Ivanov
  2025-09-19  7:00       ` Hannes Laimer
  0 siblings, 1 reply; 13+ messages in thread
From: Stoiko Ivanov @ 2025-09-18 23:21 UTC (permalink / raw)
  To: Thomas Lamprecht; +Cc: pmg-devel

On Thu, 18 Sep 2025 16:54:01 +0200
Thomas Lamprecht <t.lamprecht@proxmox.com> wrote:

> Am 18.09.25 um 16:32 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>
> > ---
> > v2:
> > - explicitly utf8 encode after `decode_rfc1522`
> > 
> >  src/PMG/CLI/pmgqm.pm | 16 ++++++++++++----
> >  1 file changed, 12 insertions(+), 4 deletions(-)
> > 
> > diff --git a/src/PMG/CLI/pmgqm.pm b/src/PMG/CLI/pmgqm.pm
> > index 41f9f1a..c26b545 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} = Encode::encode('UTF-8', PMG::Utils::decode_rfc1522($raw_subject));  
> 
> it's a bit borderline, but might be worth adding a rfc1522_to_utf8 (or
> rfc1522_to_plain_utf8?) helper for this. For one there would be a tiny
> bit better code re-use, but it would make it slightly clearer for what
> happens here.
FWIW: quickly looked through the code and currently think the encoding
here should do the sensible thing - and would agree that the helper sub
could help future reviewers see faster what's happening here.

one thing that is still passed through encode_entities is pmail (tried by
sending testmails to `discardįšų@test.domain`).

additionally it seems we do a double-encoding somewhere (probably in SMTP.pm)
but this should be unrelated to your patch.

> 
> >  
> > -    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 = Encode::encode('UTF-8', PMG::Utils::decode_rfc1522($raw_from));
> > +
> > +    my $raw_sender = PVE::Tools::trim($head->get('sender'));
> > +    my $sender = PMG::Utils::rfc1522_to_html($raw_sender);
> > +    my $sender_plain = Encode::encode('UTF-8', PMG::Utils::decode_rfc1522($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};  
> 
> 
> 
> _______________________________________________
> pmg-devel mailing list
> pmg-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
> 
> 



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [pmg-devel] [PATCH pmg-api v2 2/3] fix #1621: templates: add plain-text variant of short/verbose spam report
  2025-09-18 15:06   ` Thomas Lamprecht
@ 2025-09-18 23:26     ` Stoiko Ivanov
  2025-09-19  7:37       ` Hannes Laimer
  0 siblings, 1 reply; 13+ messages in thread
From: Stoiko Ivanov @ 2025-09-18 23:26 UTC (permalink / raw)
  To: Thomas Lamprecht; +Cc: pmg-devel

On Thu, 18 Sep 2025 17:06:44 +0200
Thomas Lamprecht <t.lamprecht@proxmox.com> wrote:

> Am 18.09.25 um 16:32 schrieb Hannes Laimer:
> > Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> > ---
> > v2:
> > - drop `subject:` line
> > 
> >  src/Makefile                              |  2 ++
> >  src/templates/spamreport-short.plain.tt   |  9 +++++++++
> >  src/templates/spamreport-verbose.plain.tt | 18 ++++++++++++++++++
> >  3 files changed, 29 insertions(+)
> >  create mode 100644 src/templates/spamreport-short.plain.tt
> >  create mode 100644 src/templates/spamreport-verbose.plain.tt
> > 
> > diff --git a/src/Makefile b/src/Makefile
> > index 896319b..b75c818 100644
> > --- a/src/Makefile
> > +++ b/src/Makefile
> > @@ -27,7 +27,9 @@ TEMPLATES =				\
> >  	fetchmailrc.tt			\
> >  	pmgreport.tt			\
> >  	spamreport-verbose.tt		\
> > +	spamreport-verbose.plain.tt	\
> >  	spamreport-short.tt		\
> > +	spamreport-short.plain.tt	\
> >  	main.cf.in			\
> >  	main.cf.in.demo			\
> >  	master.cf.in			\
> > diff --git a/src/templates/spamreport-short.plain.tt b/src/templates/spamreport-short.plain.tt
> > new file mode 100644
> > index 0000000..2c13431
> > --- /dev/null
> > +++ b/src/templates/spamreport-short.plain.tt
> > @@ -0,0 +1,9 @@
> > +You received [% mailcount %] spam mail(s).
> > +
> > +[% SET links = [] %]
> > +Manage your spam quarantine: [% n = links.size + 1; links.push(managehref); %][[% n %]]
> > +Powered by Proxmox: [% n = links.size + 1; links.push('http://www.proxmox.com'); %][[% n %]]
> > +
> > +Links:
> > +[% FOREACH l IN links %][% loop.index + 1 %]: [% l %]
> > +[% END %]
> > diff --git a/src/templates/spamreport-verbose.plain.tt b/src/templates/spamreport-verbose.plain.tt
> > new file mode 100644
> > index 0000000..1a0c182
> > --- /dev/null
> > +++ b/src/templates/spamreport-verbose.plain.tt
> > @@ -0,0 +1,18 @@
> > +[% SET links = [] -%]
> > +[% IF items.size -%]
> > +Spam quarantine entries for [% pmail %]:
> > +
> > +[% FOREACH item IN items %]
> > +- [% item.date %] [% item.time %] From: [% item.from_plain %]
> > +  Subject: [% item.subject_plain %] [% n = links.size + 1; links.push(item.href); %][[% n %]]
> > +
> > +[% END %]
> > +[% ELSE %]
> > +No spam entries for the selected period.
> > +[% END %]
> > +Manage your spam quarantine: [% n = links.size + 1; links.push(managehref); %][[% n %]]
> > +Powered by Proxmox: [% n = links.size + 1; links.push('http://www.proxmox.com'); %][[% n %]]
> > +
> > +Links:
> > +[% FOREACH l IN links %][% loop.index + 1 %]: [% l %]  
> 
> Not sure about the reference like link lists at the bottom, if there's more than a
> handful of mails in the quarantine it gets quite hard to navigate fast, albeit
> searching for the reference number naturally is an option..
> 
> Maybe put at least the general link to the web UI at the top? That might be a good
> compromise where I do not have to scroll.
> 
> I.e., move "Manage your spam quarantine" up and inline the link for that and probably
> also to www.proxmox.com as it's very short compared to the quarantine UI links anyway
> and not much is gained by placing it as reference link (and do s/http/https/ for that)
> 
> Would like to hear some other opinions here (CC'in Fabian, as he is a big plain
> text mail user too, but others are naturally welcome to chime in too).
my idea was that a single link on top pointing to the quarantine, and one
to www.proxmox.com would be enough, without listing a large link for each
individual mail. (also for the html template there's links to
block-/welcomelist mails - so there I see the advantage a bit more (vs.
pre-selecting a row))



> 
> > +[% END %]  
> 
> 
> 
> _______________________________________________
> pmg-devel mailing list
> pmg-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
> 
> 



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [pmg-devel] [PATCH pmg-api v2 1/3] pmgqm: add plain subject/from fields for reports
  2025-09-18 23:21     ` Stoiko Ivanov
@ 2025-09-19  7:00       ` Hannes Laimer
  2025-09-19 10:24         ` Stoiko Ivanov
  0 siblings, 1 reply; 13+ messages in thread
From: Hannes Laimer @ 2025-09-19  7:00 UTC (permalink / raw)
  To: Stoiko Ivanov, Thomas Lamprecht; +Cc: pmg-devel

On 19.09.25 01:21, Stoiko Ivanov wrote:
> On Thu, 18 Sep 2025 16:54:01 +0200
> Thomas Lamprecht <t.lamprecht@proxmox.com> wrote:
> 
>> Am 18.09.25 um 16:32 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>
>>> ---
>>> v2:
>>> - explicitly utf8 encode after `decode_rfc1522`
>>>
>>>   src/PMG/CLI/pmgqm.pm | 16 ++++++++++++----
>>>   1 file changed, 12 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/src/PMG/CLI/pmgqm.pm b/src/PMG/CLI/pmgqm.pm
>>> index 41f9f1a..c26b545 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} = Encode::encode('UTF-8', PMG::Utils::decode_rfc1522($raw_subject));
>>
>> it's a bit borderline, but might be worth adding a rfc1522_to_utf8 (or
>> rfc1522_to_plain_utf8?) helper for this. For one there would be a tiny
>> bit better code re-use, but it would make it slightly clearer for what
>> happens here.
> FWIW: quickly looked through the code and currently think the encoding
> here should do the sensible thing - and would agree that the helper sub
> could help future reviewers see faster what's happening here.
> 
> one thing that is still passed through encode_entities is pmail (tried by
> sending testmails to `discardįšų@test.domain`).
> 
> additionally it seems we do a double-encoding somewhere (probably in SMTP.pm)
> but this should be unrelated to your patch.
> 

We could also encode right before giving it to the template, so probably
in finalize. Since the template is actually the only thing that requires
this to be utf8 encoded.

>>
>>>   
>>> -    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 = Encode::encode('UTF-8', PMG::Utils::decode_rfc1522($raw_from));
>>> +
>>> +    my $raw_sender = PVE::Tools::trim($head->get('sender'));
>>> +    my $sender = PMG::Utils::rfc1522_to_html($raw_sender);
>>> +    my $sender_plain = Encode::encode('UTF-8', PMG::Utils::decode_rfc1522($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};
>>
>>
>>
>> _______________________________________________
>> pmg-devel mailing list
>> pmg-devel@lists.proxmox.com
>> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
>>
>>
> 



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [pmg-devel] [PATCH pmg-api v2 2/3] fix #1621: templates: add plain-text variant of short/verbose spam report
  2025-09-18 23:26     ` Stoiko Ivanov
@ 2025-09-19  7:37       ` Hannes Laimer
  0 siblings, 0 replies; 13+ messages in thread
From: Hannes Laimer @ 2025-09-19  7:37 UTC (permalink / raw)
  To: Stoiko Ivanov, Thomas Lamprecht; +Cc: pmg-devel



On 19.09.25 01:26, Stoiko Ivanov wrote:
> On Thu, 18 Sep 2025 17:06:44 +0200
> Thomas Lamprecht <t.lamprecht@proxmox.com> wrote:
> 
>> Am 18.09.25 um 16:32 schrieb Hannes Laimer:
>>> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
>>> ---
>>> v2:
>>> - drop `subject:` line
>>>
>>>   src/Makefile                              |  2 ++
>>>   src/templates/spamreport-short.plain.tt   |  9 +++++++++
>>>   src/templates/spamreport-verbose.plain.tt | 18 ++++++++++++++++++
>>>   3 files changed, 29 insertions(+)
>>>   create mode 100644 src/templates/spamreport-short.plain.tt
>>>   create mode 100644 src/templates/spamreport-verbose.plain.tt
>>>
>>> diff --git a/src/Makefile b/src/Makefile
>>> index 896319b..b75c818 100644
>>> --- a/src/Makefile
>>> +++ b/src/Makefile
>>> @@ -27,7 +27,9 @@ TEMPLATES =				\
>>>   	fetchmailrc.tt			\
>>>   	pmgreport.tt			\
>>>   	spamreport-verbose.tt		\
>>> +	spamreport-verbose.plain.tt	\
>>>   	spamreport-short.tt		\
>>> +	spamreport-short.plain.tt	\
>>>   	main.cf.in			\
>>>   	main.cf.in.demo			\
>>>   	master.cf.in			\
>>> diff --git a/src/templates/spamreport-short.plain.tt b/src/templates/spamreport-short.plain.tt
>>> new file mode 100644
>>> index 0000000..2c13431
>>> --- /dev/null
>>> +++ b/src/templates/spamreport-short.plain.tt
>>> @@ -0,0 +1,9 @@
>>> +You received [% mailcount %] spam mail(s).
>>> +
>>> +[% SET links = [] %]
>>> +Manage your spam quarantine: [% n = links.size + 1; links.push(managehref); %][[% n %]]
>>> +Powered by Proxmox: [% n = links.size + 1; links.push('http://www.proxmox.com'); %][[% n %]]
>>> +
>>> +Links:
>>> +[% FOREACH l IN links %][% loop.index + 1 %]: [% l %]
>>> +[% END %]
>>> diff --git a/src/templates/spamreport-verbose.plain.tt b/src/templates/spamreport-verbose.plain.tt
>>> new file mode 100644
>>> index 0000000..1a0c182
>>> --- /dev/null
>>> +++ b/src/templates/spamreport-verbose.plain.tt
>>> @@ -0,0 +1,18 @@
>>> +[% SET links = [] -%]
>>> +[% IF items.size -%]
>>> +Spam quarantine entries for [% pmail %]:
>>> +
>>> +[% FOREACH item IN items %]
>>> +- [% item.date %] [% item.time %] From: [% item.from_plain %]
>>> +  Subject: [% item.subject_plain %] [% n = links.size + 1; links.push(item.href); %][[% n %]]
>>> +
>>> +[% END %]
>>> +[% ELSE %]
>>> +No spam entries for the selected period.
>>> +[% END %]
>>> +Manage your spam quarantine: [% n = links.size + 1; links.push(managehref); %][[% n %]]
>>> +Powered by Proxmox: [% n = links.size + 1; links.push('http://www.proxmox.com'); %][[% n %]]
>>> +
>>> +Links:
>>> +[% FOREACH l IN links %][% loop.index + 1 %]: [% l %]
>>
>> Not sure about the reference like link lists at the bottom, if there's more than a
>> handful of mails in the quarantine it gets quite hard to navigate fast, albeit
>> searching for the reference number naturally is an option..
>>
>> Maybe put at least the general link to the web UI at the top? That might be a good
>> compromise where I do not have to scroll.
>>
>> I.e., move "Manage your spam quarantine" up and inline the link for that and probably
>> also to www.proxmox.com as it's very short compared to the quarantine UI links anyway
>> and not much is gained by placing it as reference link (and do s/http/https/ for that)
>>
>> Would like to hear some other opinions here (CC'in Fabian, as he is a big plain
>> text mail user too, but others are naturally welcome to chime in too).
> my idea was that a single link on top pointing to the quarantine, and one
> to www.proxmox.com would be enough, without listing a large link for each
> individual mail. (also for the html template there's links to
> block-/welcomelist mails - so there I see the advantage a bit more (vs.
> pre-selecting a row))
> 

makes sense, I'll send a v3

> 
> 
>>
>>> +[% END %]
>>
>>
>>
>> _______________________________________________
>> pmg-devel mailing list
>> pmg-devel@lists.proxmox.com
>> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
>>
>>
> 



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [pmg-devel] superseded: [PATCH pmg-api v2 0/3] add plain-text variants for both reports
  2025-09-18 14:31 [pmg-devel] [PATCH pmg-api v2 0/3] add plain-text variants for both reports Hannes Laimer
                   ` (2 preceding siblings ...)
  2025-09-18 14:31 ` [pmg-devel] [PATCH pmg-api v2 3/3] fix #4023: templates: add plain-text variant of admin report Hannes Laimer
@ 2025-09-19  8:37 ` Hannes Laimer
  3 siblings, 0 replies; 13+ messages in thread
From: Hannes Laimer @ 2025-09-19  8:37 UTC (permalink / raw)
  To: pmg-devel

superseded-by: 
https://lore.proxmox.com/pmg-devel/20250919083622.22955-1-h.laimer@proxmox.com/T/#t

On 18.09.25 16:32, Hannes Laimer wrote:
> This addresses both #1621 and #4023.
> 
> https://bugzilla.proxmox.com/show_bug.cgi?id=4023
> https://bugzilla.proxmox.com/show_bug.cgi?id=1621
> 
> v2, thanks @Thomas:
>   - UTF-8 encode plain-text subject/sender/from before using in templates
>   - remove `subject:` line from plain template, this is not needed in that
>     part of the mail
> 
> Hannes Laimer (3):
>    pmgqm: add plain subject/from fields for reports
>    fix #1621: templates: add plain-text variant of short/verbose spam
>      report
>    fix #4023: templates: add plain-text variant of admin report
> 
>   src/Makefile                              |  3 ++
>   src/PMG/CLI/pmgqm.pm                      | 16 ++++++--
>   src/templates/pmgreport.plain.tt          | 50 +++++++++++++++++++++++
>   src/templates/spamreport-short.plain.tt   |  9 ++++
>   src/templates/spamreport-verbose.plain.tt | 18 ++++++++
>   5 files changed, 92 insertions(+), 4 deletions(-)
>   create mode 100644 src/templates/pmgreport.plain.tt
>   create mode 100644 src/templates/spamreport-short.plain.tt
>   create mode 100644 src/templates/spamreport-verbose.plain.tt
> 



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [pmg-devel] [PATCH pmg-api v2 1/3] pmgqm: add plain subject/from fields for reports
  2025-09-19  7:00       ` Hannes Laimer
@ 2025-09-19 10:24         ` Stoiko Ivanov
  0 siblings, 0 replies; 13+ messages in thread
From: Stoiko Ivanov @ 2025-09-19 10:24 UTC (permalink / raw)
  To: Hannes Laimer; +Cc: Thomas Lamprecht, pmg-devel

On Fri, 19 Sep 2025 09:00:24 +0200
Hannes Laimer <h.laimer@proxmox.com> wrote:

> On 19.09.25 01:21, Stoiko Ivanov wrote:
> > On Thu, 18 Sep 2025 16:54:01 +0200
> > Thomas Lamprecht <t.lamprecht@proxmox.com> wrote:
> >   
> >> Am 18.09.25 um 16:32 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>
> >>> ---
> >>> v2:
> >>> - explicitly utf8 encode after `decode_rfc1522`
> >>>
> >>>   src/PMG/CLI/pmgqm.pm | 16 ++++++++++++----
> >>>   1 file changed, 12 insertions(+), 4 deletions(-)
> >>>
> >>> diff --git a/src/PMG/CLI/pmgqm.pm b/src/PMG/CLI/pmgqm.pm
> >>> index 41f9f1a..c26b545 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} = Encode::encode('UTF-8', PMG::Utils::decode_rfc1522($raw_subject));  
> >>
> >> it's a bit borderline, but might be worth adding a rfc1522_to_utf8 (or
> >> rfc1522_to_plain_utf8?) helper for this. For one there would be a tiny
> >> bit better code re-use, but it would make it slightly clearer for what
> >> happens here.  
> > FWIW: quickly looked through the code and currently think the encoding
> > here should do the sensible thing - and would agree that the helper sub
> > could help future reviewers see faster what's happening here.
> > 
> > one thing that is still passed through encode_entities is pmail (tried by
> > sending testmails to `discardįšų@test.domain`).
> > 
> > additionally it seems we do a double-encoding somewhere (probably in SMTP.pm)
> > but this should be unrelated to your patch.
> >   
> 
> We could also encode right before giving it to the template, so probably
> in finalize. Since the template is actually the only thing that requires
> this to be utf8 encoded.
hm - I think iterating over `$data` again does not gain too much - and as
it is right now - we do the encode as soon as is conveniently possible (we
fetch data from the database a few lines above.

I looked into the double-encoding - and the issue was my way of testing:
* `swaks(1)` is a great tool for testing smtp-servers - but from a quick
  look at the man-page does not consider smtputf8 at all (and postfix
  sends the things as it sees them[0], while pmg-smtp-filter relies on
  the extension keyword to decide what to do with the data)
Sending the testmails via postfix (+mutt) makes them appear correctly in
quarantine and logs.

[0] https://www.postfix.org/SMTPUTF8_README.html#detecting

> 
> >>  
> >>>   
> >>> -    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 = Encode::encode('UTF-8', PMG::Utils::decode_rfc1522($raw_from));
> >>> +
> >>> +    my $raw_sender = PVE::Tools::trim($head->get('sender'));
> >>> +    my $sender = PMG::Utils::rfc1522_to_html($raw_sender);
> >>> +    my $sender_plain = Encode::encode('UTF-8', PMG::Utils::decode_rfc1522($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};  
> >>
> >>
> >>
> >> _______________________________________________
> >> pmg-devel mailing list
> >> pmg-devel@lists.proxmox.com
> >> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
> >>
> >>  
> >   
> 



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-09-19 10:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-18 14:31 [pmg-devel] [PATCH pmg-api v2 0/3] add plain-text variants for both reports Hannes Laimer
2025-09-18 14:31 ` [pmg-devel] [PATCH pmg-api v2 1/3] pmgqm: add plain subject/from fields for reports Hannes Laimer
2025-09-18 14:54   ` Thomas Lamprecht
2025-09-18 23:21     ` Stoiko Ivanov
2025-09-19  7:00       ` Hannes Laimer
2025-09-19 10:24         ` Stoiko Ivanov
2025-09-18 14:31 ` [pmg-devel] [PATCH pmg-api v2 2/3] fix #1621: templates: add plain-text variant of short/verbose spam report Hannes Laimer
2025-09-18 15:06   ` Thomas Lamprecht
2025-09-18 23:26     ` Stoiko Ivanov
2025-09-19  7:37       ` Hannes Laimer
2025-09-18 14:31 ` [pmg-devel] [PATCH pmg-api v2 3/3] fix #4023: templates: add plain-text variant of admin report Hannes Laimer
2025-09-18 22:26   ` Stoiko Ivanov
2025-09-19  8:37 ` [pmg-devel] superseded: [PATCH pmg-api v2 0/3] add plain-text variants for both reports Hannes Laimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal