[pmg-devel] [PATCH pmg-api 1/1] Quarantine: reuse raw parameter for non htmlmail formatter

Dominik Csapak d.csapak at proxmox.com
Mon Feb 25 10:52:22 CET 2019


when we download a mail, we want the raw, unmodified header
and content in full size, so we reuse the raw parameter for
json/extjs formatter to get the full email, not only the first 4k

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PMG/API2/Quarantine.pm | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/PMG/API2/Quarantine.pm b/PMG/API2/Quarantine.pm
index 8937241..abcccdb 100644
--- a/PMG/API2/Quarantine.pm
+++ b/PMG/API2/Quarantine.pm
@@ -743,7 +743,7 @@ __PACKAGE__->register_method ({
 		maxLength => 60,
 	    },
 	    raw => {
-		description => "Display 'raw' eml data. This is only used with the 'htmlmail' formatter.",
+		description => "Display 'raw' eml data. Deactivates size limit.",
 		type => 'boolean',
 		optional => 1,
 		default => 0,
@@ -812,6 +812,8 @@ __PACKAGE__->register_method ({
 	my $role = $rpcenv->get_role();
 	my $format = $rpcenv->get_format();
 
+	my $raw = $param->{raw} // 0;
+
 	my ($cid, $rid, $tid) = $param->{id} =~ m/^C(\d+)R(\d+)T(\d+)$/;
 	$cid = int($cid);
 	$rid = int($rid);
@@ -840,7 +842,7 @@ __PACKAGE__->register_method ({
 	    my $viewimages = $cfg->get('spamquar', 'viewimages');
 	    my $allowhref = $cfg->get('spamquar', 'allowhrefs');
 
-	    $res->{content} = PMG::HTMLMail::email_to_html($path, $param->{raw}, $viewimages, $allowhref);
+	    $res->{content} = PMG::HTMLMail::email_to_html($path, $raw, $viewimages, $allowhref);
 
 	    # to make result verification happy
 	    $res->{file} = '';
@@ -850,7 +852,10 @@ __PACKAGE__->register_method ({
 	} else {
 	    # include additional details
 
-	    my ($header, $content) = PMG::HTMLMail::read_raw_email($path, 4096);
+	    # we want to get the whole email in raw mode
+	    my $maxbytes = (!$raw)? 4096 : undef;
+
+	    my ($header, $content) = PMG::HTMLMail::read_raw_email($path, $maxbytes);
 
 	    $res->{file} = $ref->{file};
 	    $res->{spaminfo} = decode_spaminfo($ref->{info});
-- 
2.11.0




More information about the pmg-devel mailing list