Handle hostnames with upper-case letters
[webmin.git] / sendmail / qdetach.cgi
1 #!/usr/local/bin/perl
2 # detach.cgi
3 # View one attachment from a message
4
5 require './sendmail-lib.pl';
6 require './boxes-lib.pl';
7
8 &ReadParse();
9 $access{'mailq'} || &error($text{'mailq_ecannot'});
10 $in{'file'} =~ /\.\./ && &error($text{'mailq_ecannot'});
11 $conf = &get_sendmailcf();
12 foreach $mqueue (&mailq_dir($conf)) {
13         $ok++ if ($in{'file'} =~ /^$mqueue\//);
14         }
15 $ok || &error($text{'mailq_ecannot'});
16
17 $qfile = $in{'file'};
18 ($dfile = $qfile) =~ s/\/(qf|hf|Qf)/\/df/;
19 $mail = &mail_from_queue($qfile, $dfile);
20 &parse_mail($mail);
21 @sub = split(/\0/, $in{'sub'});
22 foreach $s (@sub) {
23         # We are looking at a mail within a mail ..
24         local $amail = &extract_mail($mail->{'attach'}->[$s]->{'data'});
25         &parse_mail($amail);
26         $mail = $amail;
27         }
28 $attach = $mail->{'attach'}->[$in{'attach'}];
29
30 print "X-no-links: 1\n";
31 if ($attach->{'type'} eq 'message/delivery-status') {
32         print "Content-type: text/plain\n\n";
33         }
34 else {
35         print "Content-type: $attach->{'type'}\n\n";
36         }
37 if ($attach->{'type'} =~ /^text\/html/i) {
38         print &filter_javascript($attach->{'data'});
39         }
40 else {
41         print $attach->{'data'};
42         }
43