perl cgi解压上载的文件
我在一个web服务器上工作,用户可以上传zip文件。上传后,它应该解压文件。我尝试了系统命令unzip以及perl cgi解压上载的文件,perl,upload,cgi,unzip,Perl,Upload,Cgi,Unzip,我在一个web服务器上工作,用户可以上传zip文件。上传后,它应该解压文件。我尝试了系统命令unzip以及Archive::Extract模块。我仍然得到错误: Insecure dependency in eval while running with -T switch at /usr/lib/perl5/5.10.0/Module/Load/Conditional.pm line 332, <GEN3> line 34 在/usr/lib/perl5/5.10.0/Modul
Archive::Extract
模块。我仍然得到错误:
Insecure dependency in eval while running with -T switch at /usr/lib/perl5/5.10.0/Module/Load/Conditional.pm line 332, <GEN3> line 34
在/usr/lib/perl5/5.10.0/Module/Load/Conditional.pm第332行和第34行使用-T开关运行时,eval中的依赖关系不安全
请帮忙。我想你在做类似的事情
system "unzip $value_from_browser";
因此,整个过程就是邀请shell代码注入(浏览器中的文件名为“bla.zip;rm-fr*”)
使用多参数语法,避免使用shell:
system 'unzip', $value_from_browser;
一种更安全的方法可能是使用
Archive::zip
,这里是我的一些工作代码,它应该会告诉您如何做的要点。Archive::zip
模块也有一些信息
sub unpack_zipfiles
{
my $zipfile = shift; # Name of uploaded zip file
my $zip = Archive::Zip->new();
my $status = $zip->read($zipfile);
if ($status == AZ_OK )
{
my @members = $zip->memberNames();
my $n = 1;
foreach my $f (@members)
{
my @f2 = split(/\//,$f);
# Part 1 - get a filename, and save the file
my $zf = getNextFile($f2[$#f2]);
my $unzipped = qq{$unpack_dir/$zf};
$zip->extractMemberWithoutPaths($f,$unzipped);
# Part 2 - check if it's new or the same, and adjust the filename if necessary
$zf = check_or_revert($unpack_dir,$zf,$f2[$#f2]);
$n++;
push @msgs,qq{Unzipped file: $zf};
# Add file to list of unpacked file (for diagnostic purposes)
push @{$data{unpacked}},$unzipped;
# Unzipped files are plonked back in the file queue, because there is a loop that deals with them.
push @{$data{fileq}},$unzipped;
}
}
else
{
die "Error: $zipfile is not a valid zip file, Zip status=$status";
}
}