[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm londocs.pm
raeburn
raeburn at source.lon-capa.org
Sun Mar 9 11:49:49 EDT 2014
raeburn Sun Mar 9 15:49:49 2014 EDT
Modified files:
/loncom/interface londocs.pm loncommon.pm
Log:
- Decompression of archive files uploaded to a course.
- Check extension for uploaded file identified as an archive file by
File::MMagic, in orer to exclude xlsx, docx, pptx
(for which reported mime-type is application/x-zip).
- Consistent extension checking in londocs::process_file_upload()
and loncommon::process_decompression() -- case insensitive.
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.577 loncom/interface/londocs.pm:1.578
--- loncom/interface/londocs.pm:1.577 Tue Feb 11 19:11:24 2014
+++ loncom/interface/londocs.pm Sun Mar 9 15:49:48 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.577 2014/02/11 19:11:24 bisitz Exp $
+# $Id: londocs.pm,v 1.578 2014/03/09 15:49:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -46,6 +46,7 @@
use HTML::Entities;
use HTML::TokeParser;
use GDBM_File;
+use File::MMagic;
use Apache::lonlocal;
use Cwd;
use LONCAPA qw(:DEFAULT :match);
@@ -3280,7 +3281,8 @@
$$upload_output .= &mt('No embedded items identified').'<br />';
}
$$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
- } elsif (&Apache::loncommon::is_archive_file($mimetype)) {
+ } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
+ ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
$nextphase = 'decompress_uploaded';
my $position = scalar(@LONCAPA::map::order)-1;
my $noextract = &return_to_editor();
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1179 loncom/interface/loncommon.pm:1.1180
--- loncom/interface/loncommon.pm:1.1179 Thu Feb 27 12:41:24 2014
+++ loncom/interface/loncommon.pm Sun Mar 9 15:49:48 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1179 2014/02/27 12:41:24 bisitz Exp $
+# $Id: loncommon.pm,v 1.1180 2014/03/09 15:49:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -11272,7 +11272,7 @@
sub process_decompression {
my ($docudom,$docuname,$file,$destination,$dir_root,$hiddenelem) = @_;
my ($dir,$error,$warning,$output);
- if ($file !~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/) {
+ if ($file !~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i) {
$error = &mt('Filename not a supported archive file type.').
'<br />'.&mt('Filename should end with one of: [_1].',
'.zip, .tar, .bz2, .gz, .tar.gz, .tar.bz2, .tgz');
More information about the LON-CAPA-cvs
mailing list