often, the users want to show the *decoded* header, iow. they want
to see the readable subject,from,to, etc. not the quoted-printable
versions.
so add a new parameter that decodes the header lines as we read them
using MIME::WordDecoder's 'mime_to_perl_string'.
for backwards compatibility, this is not the default in the api
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
default => 0,
optional => 1,
},
+ 'decode-header' => {
+ description => "Decodes the header fields.",
+ type => 'boolean',
+ default => 0,
+ optional => 1,
+ },
},
},
returns => { type => 'string' },
$param->{header} //= 1;
- return PMG::Postfix::postcat($param->{queue_id}, $param->{header}, $param->{body});
+ return PMG::Postfix::postcat($param->{queue_id}, $param->{header}, $param->{body}, $param->{'decode-header'});
}});
__PACKAGE__->register_method ({
use Data::Dumper;
use File::Find;
use JSON;
+use MIME::WordDecoder qw(mime_to_perl_string);
use PVE::Tools;
}
sub postcat {
- my ($queue_id, $header, $body) = @_;
+ my ($queue_id, $header, $body, $decode) = @_;
die "no option specified (select header or body or both)"
if !($header || $body);
my $res = '';
while (defined(my $line = <$fh>)) {
+ if ($decode) {
+ $line = mime_to_perl_string($line);
+ }
$res .= $line;
}