fixed various bugs with new date/time and added new Apache2::Upload functionality to Storage.
This commit is contained in:
parent
fec3edd516
commit
f3e5107811
2 changed files with 29 additions and 28 deletions
|
|
@ -14,7 +14,7 @@ package WebGUI::Asset::Wobject;
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
use CGI::Util qw(rearrange);
|
#use CGI::Util qw(rearrange);
|
||||||
use DBI;
|
use DBI;
|
||||||
use strict qw(subs vars);
|
use strict qw(subs vars);
|
||||||
use Tie::IxHash;
|
use Tie::IxHash;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ use WebGUI::Id;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::URL;
|
use WebGUI::URL;
|
||||||
use WebGUI::Utility;
|
use WebGUI::Utility;
|
||||||
|
use Apache2::Request;
|
||||||
|
use Apache2::Upload;
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
|
|
@ -199,35 +201,34 @@ sub addFileFromFormPost {
|
||||||
return "" if (WebGUI::HTTP::getStatus() =~ /^413/);
|
return "" if (WebGUI::HTTP::getStatus() =~ /^413/);
|
||||||
my $filename;
|
my $filename;
|
||||||
my $attachmentCount = 1;
|
my $attachmentCount = 1;
|
||||||
foreach my $tempPath ($session{req}->upload($formVariableName)) {
|
foreach my $upload ($session{req}->upload($formVariableName)) {
|
||||||
last if $attachmentCount > $attachmentLimit;
|
last if $attachmentCount > $attachmentLimit;
|
||||||
if ($tempPath =~ /([^\/\\]+)$/) {
|
my $tempPath = $upload->tempname();
|
||||||
$filename = $1;
|
$filename = $upload->filename();
|
||||||
} else {
|
next unless $filename;
|
||||||
$filename = $tempPath;
|
my $type = $self->getFileExtension($filename);
|
||||||
}
|
if (isIn($type, qw(pl perl sh cgi php asp))) { # make us safe from malicious uploads
|
||||||
my $type = $self->getFileExtension($filename);
|
$filename =~ s/\./\_/g;
|
||||||
if (isIn($type, qw(pl perl sh cgi php asp))) { # make us safe from malicious uploads
|
$filename .= ".txt";
|
||||||
$filename =~ s/\./\_/g;
|
}
|
||||||
$filename .= ".txt";
|
$filename = WebGUI::URL::makeCompliant($filename);
|
||||||
}
|
|
||||||
$filename = WebGUI::URL::makeCompliant($filename);
|
|
||||||
my $bytesread;
|
my $bytesread;
|
||||||
my $file = FileHandle->new(">".$self->getPath($filename));
|
my $file = FileHandle->new(">".$self->getPath($filename));
|
||||||
$attachmentCount++;
|
$attachmentCount++;
|
||||||
if (defined $file) {
|
if (defined $file) {
|
||||||
my $buffer;
|
my $buffer;
|
||||||
binmode $file;
|
my $sourcefh = $upload->fh;
|
||||||
while ($bytesread=read($tempPath,$buffer,1024)) {
|
binmode $file;
|
||||||
print $file $buffer;
|
while ($bytesread=read($sourcefh,$buffer,1024)) {
|
||||||
}
|
print $file $buffer;
|
||||||
close($file);
|
}
|
||||||
} else {
|
close($file);
|
||||||
$self->_addError("Couldn't open file ".$self->getPath($filename)." for writing due to error: ".$!);
|
} else {
|
||||||
return undef;
|
$self->_addError("Couldn't open file ".$self->getPath($filename)." for writing due to error: ".$!);
|
||||||
}
|
return undef;
|
||||||
}
|
}
|
||||||
return $filename;
|
}
|
||||||
|
return $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue