Print Verbatim Onecapitaltopic
Testing
Bugs.Item2979
sub sanitizeAttachmentName {
my $fileName = shift;
# homegrown split because File::Spec functions will assume that directory path is using / in UNIX and \ in Windows as defined in the HOST environment.
# And we don't know the client OS. Problem is specific to IE which sends the full original client path when you upload files. See Item2859 and Item2225 before
# trying again to use File::Spec functions and remember to test with IE. Cut path from filepath name (Windows '\' and Unix "/" format)
my @pathz = ( split( /\\/, $fileName ) );
my $filetemp = $pathz[$#pathz];
my @pathza = ( split( '/', $filetemp ) );
$filetemp = $pathza[$#pathza];
# untaint
$fileName = untaintUnchecked($filetemp);
my $origName = $fileName;
# Change spaces to underscore
$fileName =~ s/ /_/go;
# Remove problematic chars
$fileName =~ s/$TWiki::cfg{NameFilter}//goi;
# Append .txt to some files
$fileName =~ s/$TWiki::cfg{UploadFilter}/$1\.txt/goi;
return ($fileName, $origName);
}
sub sanitizeAttachmentName {
my $fileName = shift;
# homegrown split because File::Spec functions will assume that directory path is using / in UNIX and \ in Windows as defined in the HOST environment.
# And we don't know the client OS. Problem is specific to IE which sends the full original client path when you upload files. See Item2859 and Item2225 before
# trying again to use File::Spec functions and remember to test with IE. Cut path from filepath name (Windows '\' and Unix "/" format)
my @pathz = ( split( /\\/, $fileName ) );
my $filetemp = $pathz[$#pathz];
my @pathza = ( split( '/', $filetemp ) );
$filetemp = $pathza[$#pathza];
# untaint
$fileName = untaintUnchecked($filetemp);
my $origName = $fileName;
# Change spaces to underscore
$fileName =~ s/ /_/go;
# Remove problematic chars
$fileName =~ s/$TWiki::cfg{NameFilter}//goi;
# Append .txt to some files
$fileName =~ s/$TWiki::cfg{UploadFilter}/$1\.txt/goi;
return ($fileName, $origName);
}
sub sanitizeAttachmentName {
my $fileName = shift;
# homegrown split because File::Spec functions will assume that directory path is using / in UNIX and \ in Windows as defined in the HOST environment.
# And we don't know the client OS. Problem is specific to IE which sends the full original client path when you upload files. See Item2859 and Item2225 before
# trying again to use File::Spec functions and remember to test with IE. Cut path from filepath name (Windows '\' and Unix "/" format)
my @pathz = ( split( /\\/, $fileName ) );
my $filetemp = $pathz[$#pathz];
my @pathza = ( split( '/', $filetemp ) );
$filetemp = $pathza[$#pathza];
# untaint
$fileName = untaintUnchecked($filetemp);
my $origName = $fileName;
# Change spaces to underscore
$fileName =~ s/ /_/go;
# Remove problematic chars
$fileName =~ s/$TWiki::cfg{NameFilter}//goi;
# Append .txt to some files
$fileName =~ s/$TWiki::cfg{UploadFilter}/$1\.txt/goi;
return ($fileName, $origName);
}
sub sanitizeAttachmentName {
my $fileName = shift;
# homegrown split because File::Spec functions will assume that directory path is using / in UNIX and \ in Windows as defined in the HOST environment.
# And we don't know the client OS. Problem is specific to IE which sends the full original client path when you upload files. See Item2859 and Item2225 before
# trying again to use File::Spec functions and remember to test with IE. Cut path from filepath name (Windows '\' and Unix "/" format)
my @pathz = ( split( /\\/, $fileName ) );
my $filetemp = $pathz[$#pathz];
my @pathza = ( split( '/', $filetemp ) );
$filetemp = $pathza[$#pathza];
# untaint
$fileName = untaintUnchecked($filetemp);
my $origName = $fileName;
# Change spaces to underscore
$fileName =~ s/ /_/go;
# Remove problematic chars
$fileName =~ s/$TWiki::cfg{NameFilter}//goi;
# Append .txt to some files
$fileName =~ s/$TWiki::cfg{UploadFilter}/$1\.txt/goi;
return ($fileName, $origName);
}
sub sanitizeAttachmentName {
my $fileName = shift;
# homegrown split because File::Spec functions will assume that directory path is using / in UNIX and \ in Windows as defined in the HOST environment.
# And we don't know the client OS. Problem is specific to IE which sends the full original client path when you upload files. See Item2859 and Item2225 before
# trying again to use File::Spec functions and remember to test with IE. Cut path from filepath name (Windows '\' and Unix "/" format)
my @pathz = ( split( /\\/, $fileName ) );
my $filetemp = $pathz[$#pathz];
my @pathza = ( split( '/', $filetemp ) );
$filetemp = $pathza[$#pathza];
# untaint
$fileName = untaintUnchecked($filetemp);
my $origName = $fileName;
# Change spaces to underscore
$fileName =~ s/ /_/go;
# Remove problematic chars
$fileName =~ s/$TWiki::cfg{NameFilter}//goi;
# Append .txt to some files
$fileName =~ s/$TWiki::cfg{UploadFilter}/$1\.txt/goi;
return ($fileName, $origName);
}
sub sanitizeAttachmentName {
my $fileName = shift;
# homegrown split because File::Spec functions will assume that directory path is using / in UNIX and \ in Windows as defined in the HOST environment.
# And we don't know the client OS. Problem is specific to IE which sends the full original client path when you upload files. See Item2859 and Item2225 before
# trying again to use File::Spec functions and remember to test with IE. Cut path from filepath name (Windows '\' and Unix "/" format)
my @pathz = ( split( /\\/, $fileName ) );
my $filetemp = $pathz[$#pathz];
my @pathza = ( split( '/', $filetemp ) );
$filetemp = $pathza[$#pathza];
# untaint
$fileName = untaintUnchecked($filetemp);
my $origName = $fileName;
# Change spaces to underscore
$fileName =~ s/ /_/go;
# Remove problematic chars
$fileName =~ s/$TWiki::cfg{NameFilter}//goi;
# Append .txt to some files
$fileName =~ s/$TWiki::cfg{UploadFilter}/$1\.txt/goi;
return ($fileName, $origName);
}
sub sanitizeAttachmentName {
my $fileName = shift;
# homegrown split because File::Spec functions will assume that directory path is using / in UNIX and \ in Windows as defined in the HOST environment.
# And we don't know the client OS. Problem is specific to IE which sends the full original client path when you upload files. See Item2859 and Item2225 before
# trying again to use File::Spec functions and remember to test with IE. Cut path from filepath name (Windows '\' and Unix "/" format)
my @pathz = ( split( /\\/, $fileName ) );
my $filetemp = $pathz[$#pathz];
my @pathza = ( split( '/', $filetemp ) );
$filetemp = $pathza[$#pathza];
# untaint
$fileName = untaintUnchecked($filetemp);
my $origName = $fileName;
# Change spaces to underscore
$fileName =~ s/ /_/go;
# Remove problematic chars
$fileName =~ s/$TWiki::cfg{NameFilter}//goi;
# Append .txt to some files
$fileName =~ s/$TWiki::cfg{UploadFilter}/$1\.txt/goi;
return ($fileName, $origName);
}
THIS IS THE END OF THE VERBATIM BLOCK
--
PeterThoeny - 20 Oct 2006