]> git.proxmox.com Git - pmg-api.git/commitdiff
Quarantine: reuse raw parameter for non htmlmail formatter
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 25 Feb 2019 09:52:22 +0000 (10:52 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 26 Feb 2019 09:45:50 +0000 (10:45 +0100)
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@proxmox.com>
PMG/API2/Quarantine.pm

index 89372419ccbebf763b37d988f5a715239e75be58..abcccdb099d114aed2c8b466c0695db458994727 100644 (file)
@@ -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});