* [pmg-devel] [PATCH pmg-api] pmgdb dump: encode ruledata before printing
@ 2022-11-30 13:21 Stoiko Ivanov
2022-12-15 11:10 ` Dominik Csapak
2022-12-30 14:18 ` [pmg-devel] applied: " Thomas Lamprecht
0 siblings, 2 replies; 3+ messages in thread
From: Stoiko Ivanov @ 2022-11-30 13:21 UTC (permalink / raw)
To: pmg-devel
was overlooked with the utf-8 support for rules and objects
this patch prevents a "Wide character in print at .." when dumping the
ruledata
Reported-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
src/PMG/CLI/pmgdb.pm | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/PMG/CLI/pmgdb.pm b/src/PMG/CLI/pmgdb.pm
index 417e008..8368af8 100644
--- a/src/PMG/CLI/pmgdb.pm
+++ b/src/PMG/CLI/pmgdb.pm
@@ -3,6 +3,7 @@ package PMG::CLI::pmgdb;
use strict;
use warnings;
use Data::Dumper;
+use Encode qw(encode);
use PVE::SafeSyslog;
use PVE::Tools qw(extract_param);
@@ -31,7 +32,7 @@ sub print_objects {
my $objects = $ruledb->load_group_objects ($og->{id});
foreach my $obj (@$objects) {
- my $desc = $obj->short_desc ();
+ my $desc = encode('UTF-8', $obj->short_desc());
print " OBJECT $obj->{id}: $desc\n";
}
}
@@ -46,31 +47,34 @@ sub print_rule {
};
my $active = $rule->{active} ? 'active' : 'inactive';
my $dir = $direction->{$rule->{direction}};
+ my $rulename = encode('UTF-8', $rule->{name});
- print "Found RULE $rule->{id} (prio: $rule->{priority}, $dir, $active): $rule->{name}\n";
+ print "Found RULE $rule->{id} (prio: $rule->{priority}, $dir, $active): $rulename\n";
+
+ my $print_group = sub {
+ my ($type, $og) = @_;
+ my $oname = encode('UTF-8', $og->{name});
+ print " FOUND $type GROUP $og->{id}: $oname\n";
+ print_objects($ruledb, $og);
+ };
my ($from, $to, $when, $what, $action) =
$ruledb->load_groups($rule);
foreach my $og (@$from) {
- print " FOUND FROM GROUP $og->{id}: $og->{name}\n";
- print_objects($ruledb, $og);
+ $print_group->("FROM", $og);
}
foreach my $og (@$to) {
- print " FOUND TO GROUP $og->{id}: $og->{name}\n";
- print_objects($ruledb, $og);
+ $print_group->("TO", $og);
}
foreach my $og (@$when) {
- print " FOUND WHEN GROUP $og->{id}: $og->{name}\n";
- print_objects($ruledb, $og);
+ $print_group->("WHEN", $og);
}
foreach my $og (@$what) {
- print " FOUND WHAT GROUP $og->{id}: $og->{name}\n";
- print_objects($ruledb, $og);
+ $print_group->("WHAT", $og);
}
foreach my $og (@$action) {
- print " FOUND ACTION GROUP $og->{id}: $og->{name}\n";
- print_objects($ruledb, $og);
+ $print_group->("ACTION", $og);
}
}
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pmg-devel] [PATCH pmg-api] pmgdb dump: encode ruledata before printing
2022-11-30 13:21 [pmg-devel] [PATCH pmg-api] pmgdb dump: encode ruledata before printing Stoiko Ivanov
@ 2022-12-15 11:10 ` Dominik Csapak
2022-12-30 14:18 ` [pmg-devel] applied: " Thomas Lamprecht
1 sibling, 0 replies; 3+ messages in thread
From: Dominik Csapak @ 2022-12-15 11:10 UTC (permalink / raw)
To: Stoiko Ivanov, pmg-devel
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pmg-devel] applied: [PATCH pmg-api] pmgdb dump: encode ruledata before printing
2022-11-30 13:21 [pmg-devel] [PATCH pmg-api] pmgdb dump: encode ruledata before printing Stoiko Ivanov
2022-12-15 11:10 ` Dominik Csapak
@ 2022-12-30 14:18 ` Thomas Lamprecht
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2022-12-30 14:18 UTC (permalink / raw)
To: Stoiko Ivanov, pmg-devel
Am 30/11/2022 um 14:21 schrieb Stoiko Ivanov:
> was overlooked with the utf-8 support for rules and objects
>
> this patch prevents a "Wide character in print at .." when dumping the
> ruledata
>
> Reported-by: Dominik Csapak <d.csapak@proxmox.com>
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
> src/PMG/CLI/pmgdb.pm | 28 ++++++++++++++++------------
> 1 file changed, 16 insertions(+), 12 deletions(-)
>
>
for the record: this got already applied by Stoiko with Dominik's R-b and T-b trailers
https://git.proxmox.com/?p=pmg-api.git;a=commit;h=99447a919dfc019eaa3a9e413fb9f60af5313711
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-30 14:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-30 13:21 [pmg-devel] [PATCH pmg-api] pmgdb dump: encode ruledata before printing Stoiko Ivanov
2022-12-15 11:10 ` Dominik Csapak
2022-12-30 14:18 ` [pmg-devel] applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox