Files
webmin/postfix/detach_queue.cgi
Jamie Cameron dda9b972b9
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled
Close inactive / close-inactive (push) Has been cancelled
Protect against SVG attachments in the mail queue
2026-10-14 21:21:22 -07:00

32 lines
790 B
Perl
Executable File

#!/usr/local/bin/perl
# detach_queue.cgi
# View one attachment from a queued message
require './postfix-lib.pl'; ## no critic
use strict;
use warnings;
our ($attach, $mail, %access, %in, %text);
require './boxes-lib.pl'; ## no critic
&ReadParse();
$access{'mailq'} || &error($text{'mailq_ecannot'});
$mail = &parse_queue_file($in{'id'});
$mail || &error($text{'mailq_egone'});
&parse_mail($mail);
$attach = $mail->{'attach'}->[$in{'attach'}];
print "X-no-links: 1\n";
if ($attach->{'type'} eq 'message/delivery-status') {
print "Content-type: text/plain\n\n";
}
else {
print "Content-type: $attach->{'type'}\n\n";
}
if ($attach->{'type'} =~ /^(text\/html|image\/svg|application\/xhtml)/i) {
print &filter_javascript($attach->{'data'});
}
else {
print $attach->{'data'};
}