[LON-CAPA-cvs] cvs: loncom /cgi decompress.pl

albertel lon-capa-cvs@mail.lon-capa.org
Sat, 13 Dec 2003 00:20:47 -0000


albertel		Fri Dec 12 19:20:47 2003 EDT

  Modified files:              
    /loncom/cgi	decompress.pl 
  Log:
  - match the extension only (was mishandling zip.tar)
  - match case insesitively
  
  
Index: loncom/cgi/decompress.pl
diff -u loncom/cgi/decompress.pl:1.10 loncom/cgi/decompress.pl:1.11
--- loncom/cgi/decompress.pl:1.10	Wed Nov 19 15:03:39 2003
+++ loncom/cgi/decompress.pl	Fri Dec 12 19:20:47 2003
@@ -48,43 +48,43 @@
 	<html><body><b>Output of decompress:</b><br /><br />
 END
         chdir $ENV{'cgi.dir'};
-        if ($ENV{'cgi.file'} =~ m|zip|) {
-            open(OUTPUT, "unzip $ENV{'cgi.file'} 2> /dev/null |");
+        if ($ENV{'cgi.file'} =~ m|\.zip$|i) {
+            open(OUTPUT, "unzip -o $ENV{'cgi.file'} 2> /dev/null |");
             while (<OUTPUT>) {
                 print "$_<br />";
             }
             close(OUTPUT);
-        } elsif ($ENV{'cgi.file'} =~ m|tar.gz|) {
+        } elsif ($ENV{'cgi.file'} =~ m|\.tar\.gz$|i) {
             open(OUTPUT, "tar -zxpvf $ENV{'cgi.file'} 2> /dev/null |");
             while (<OUTPUT>) {
                 print "$_<br />";
             }
             close(OUTPUT);
-        } elsif ($ENV{'cgi.file'} =~ m|tar.bz2|) {
+        } elsif ($ENV{'cgi.file'} =~ m|\.tar\.bz2$|i) {
             open(OUTPUT, "tar -jxpvf $ENV{'cgi.file'} 2> /dev/null |");
             while (<OUTPUT>) {
                 print "$_<br />";
             }
             close(OUTPUT);
-        } elsif ($ENV{'cgi.file'} =~ m|bz2|) {
+        } elsif ($ENV{'cgi.file'} =~ m|\.bz2$|i) {
             open(OUTPUT, "bunzip2 $ENV{'cgi.file'} 2> /dev/null |");
             while (<OUTPUT>) {
                 print "$_<br />";
             }
             close(OUTPUT);
-        } elsif ($ENV{'cgi.file'} =~ m|tgz|) {
+        } elsif ($ENV{'cgi.file'} =~ m|\.tgz$|i) {
             open(OUTPUT, "tar -zxpvf $ENV{'cgi.file'} 2> /dev/null |");
             while (<OUTPUT>) {
                 print "$_<br />";
             }
             close(OUTPUT);
-        } elsif ($ENV{'cgi.file'} =~ m|gz|) {
+        } elsif ($ENV{'cgi.file'} =~ m|\.gz$|i) {
             open(OUTPUT, "gunzip $ENV{'cgi.file'} 2> /dev/null |");
             while (<OUTPUT>) {
                 print "$_<br />";
             }
             close(OUTPUT);
-        } elsif ($ENV{'cgi.file'} =~ m|tar|) {
+        } elsif ($ENV{'cgi.file'} =~ m|\.tar$|i) {
             open(OUTPUT, "tar -xpvf $ENV{'cgi.file'} 2> /dev/null |");
             while (<OUTPUT>) {
                 print "$_<br />";