Support multiple files per attachment field

This commit is contained in:
Jamie Cameron
2016-01-23 17:58:54 -08:00
parent 9040c26581
commit bb98a1af45
3 changed files with 26 additions and 17 deletions
+2
View File
@@ -73,3 +73,5 @@ When reading email via a link from Virtualmin, the "return to user list" link re
When a language with a UTF-8 character set is selected, email is converted to UTF-8 before being displayed. This allows an inbox with mixed language subject lines to be properly displayed.
---- Changes since 1.720 ----
All operations on user mailboxes are now performed with the permissions of the user, to prevent attacks using malicious symlinks.
---- Changes since 1.780 ----
When attaching files to a message, multiple files can now be selected at the same time.
+1 -1
View File
@@ -3535,7 +3535,7 @@ if (!$main::no_browser_uploads) {
my $atable = "<div>\n";
for(my $i=0; $i<$count; $i++) {
$atable .= &ui_upload("attach$i", 80, 0,
"style='width:100%'")."<br>";
"style='width:100%'", 1)."<br>";
}
$atable .= "</div> <div id=attachblock></div>\n";
print &ui_hidden("attachcount", int($i)),"\n";
+23 -16
View File
@@ -4,7 +4,10 @@
require './mailboxes-lib.pl';
&ReadParse(\%getin, "GET");
&ReadParseMime(undef, \&read_parse_mime_callback, [ $getin{'id'} ]);
&ReadParseMime(undef, \&read_parse_mime_callback, [ $getin{'id'} ], 1);
foreach my $k (keys %in) {
$in{$k} = $in{$k}->[0] if ($k !~ /^attach\d+/);
}
&can_user($in{'user'}) || &error($text{'mail_ecannot'});
@uinfo = &get_mail_user($in{'user'});
@uinfo || &error($text{'view_eugone'});
@@ -137,25 +140,29 @@ if ($in{'body'} =~ /\S/) {
};
}
}
$attachsize = 0;
for($i=0; defined($in{"attach$i"}); $i++) {
# Add uploaded attachment
next if (!$in{"attach$i"});
&test_max_attach($attachsize);
local $filename = $in{"attach${i}_filename"};
$filename =~ s/^.*(\\|\/)//;
local $type = $in{"attach${i}_content_type"}."; name=\"".
$filename."\"";
local $disp = "inline; filename=\"".$filename."\"";
push(@attach, { 'data' => $in{"attach${i}"},
'headers' => [ [ 'Content-type', $type ],
[ 'Content-Disposition', $disp ],
[ 'Content-Transfer-Encoding',
'base64' ] ] });
$atotal += length($in{"attach${i}"});
}
next if (!$in{"attach$i"});
for($j=0; $j<@{$in{"attach$i"}}; $j++) {
next if (!$in{"attach${i}"}->[$j]);
&test_max_attach(length($in{"attach${i}"}->[$j]));
local $filename = $in{"attach${i}_filename"}->[$j];
$filename =~ s/^.*(\\|\/)//;
local $type = $in{"attach${i}_content_type"}->[$j].
"; name=\"".$filename."\"";
local $disp = "attachment; filename=\"".$filename."\"";
push(@attach, { 'data' => $in{"attach${i}"}->[$j],
'headers' => [ [ 'Content-type', $type ],
[ 'Content-Disposition', $disp ],
[ 'Content-Transfer-Encoding',
'base64' ] ] });
$atotal += length($in{"attach${i}"}->[$j]);
}
}
for($i=0; defined($in{"file$i"}); $i++) {
# Add uploaded attachment
# Add server-side attachment
next if (!$in{"file$i"} || !$access{'canattach'});
@uinfo = &get_mail_user($in{'user'});