deb.in.diff, another try



Hi,

Reading Jakub's analysis I seriously started to doubt my use of map, and
the fact that I quote where it is not necessary. I thought the double
quoting was harmless, but it appears not to be.

In this version I use both escaped and none escaped parameters as
necessary. I hope I got it right this time...

Leonard.

-- 
mount -t life -o ro /dev/dna /genetic/research

--- deb.in.000	2004-08-17 22:57:09.000000000 +0200
+++ deb.in	2004-08-19 18:11:31.000000000 +0200
@@ -26,8 +26,10 @@ sub mcdebfs_list
 #		Empty directories do not appear at all
 #
 	local($archivename)= _;
+	local $qarchivename = $archivename;
+	$qarchivename =~ s/([^\w\/.+-])/\\$1/g;
 	chop($date=`LC_ALL=C date "+%b %d %Y %H:%M"`);
-	chop($info_size=`dpkg -I $archivename | wc -c`);
+	chop($info_size=`dpkg -I $qarchivename | wc -c`);
 	$install_size=length($pressinstall);
 
 	print "dr-xr-xr-x   1 root     root     0 $date CONTENTS\n";
@@ -36,7 +38,7 @@ sub mcdebfs_list
 	print "-r--r--r--   1 root     root     $info_size $date INFO\n";
 	print "-r-xr--r--   1 root     root     $install_size $date INSTALL\n";
 
-	if ( open(PIPEIN, "dpkg-deb -c $archivename |") )
+	if ( open(PIPEIN, "dpkg-deb -c $qarchivename |") )
 	{
 		while(<PIPEIN>)
 		{
@@ -81,7 +83,7 @@ sub mcdebfs_list
 		}
 	}
         # begin from Patrik Rak
-        if ( open(PIPEIN, "dpkg-deb -I $archivename |") )
+        if ( open(PIPEIN, "dpkg-deb -I $qarchivename |") )
         {
                while(<PIPEIN>)
                {
@@ -109,16 +111,22 @@ sub mcdebfs_list
 sub mcdebfs_copyout
 {
 	local($archive,$filename,$destfile)= _;
+	local $qarchive = $archive;
+	$qarchive =~ s/([^\w\/.+-])/\\$1/g;
+	local $qfilename = $filename;
+	$qfilename =~ s/([^\w\/.+-])/\\$1/g;
+	local $qdestfile = $destfile;
+	$qdestfile =~ s/([^\w\/.+-])/\\$1/g;
 
 	if($filename eq "INFO")
 	{
-		system("dpkg-deb -I $archive > $destfile");
+		system("dpkg-deb -I $qarchive > $qdestfile");
         # begin from Patrik Rak
         }
         elsif($filename =~ /^DEBIAN/)
         {
                $filename=~s!^DEBIAN/!!;
-               system("dpkg-deb -I $archive $filename > $destfile");
+               system("dpkg-deb -I $qarchive $qfilename > $qdestfile");
         # end from Patrik Rak
 
 	}
@@ -128,24 +136,26 @@ sub mcdebfs_copyout
 		{
 			print FILEOUT $pressinstall;
 			close FILEOUT;
-			system("chmod a+x $destfile");
+			system("chmod a+x $qdestfile");
 		}
 	}
 	else
 	{
 	# files can be prepended with ./ or not, depending on the version of tar
 		$filename=~s!^CONTENTS/!!;
-		system("dpkg-deb --fsys-tarfile $archive | tar xOf - $filename ./$filename > $destfile 2>/dev/null");
+		system("dpkg-deb --fsys-tarfile $qarchive | tar xOf - $qfilename ./$qfilename > $qdestfile 2>/dev/null");
 	}
 }
 
 sub mcdebfs_run
 {
 	local($archive,$filename)= _;
+	local $qarchive = $archive;
+	$qarchive =~ s/([^\w\/.+-])/\\$1/g;
 	if($filename eq "INSTALL")
 	{
 		print "Installing $archive\n";
-		system("dpkg -i $archive");
+		system("dpkg -i $qarchive");
 	}
 	else
 	{


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]