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

Bug#251048: apache-common: listconffiles doesn't cope well with extra whitespace



Fab, 
I spent some time checking the behaviour of listconffiles and
came up with the following patch. This takes care of a couple more
special cases than those reported in this bug, i.e. spaces after the
file name and a comment (possibly preceded by spaces) after the
filename. I hope there are no more special cases to take into account.

Here's the patch, and the full modified file is attached for your
convenience too. 

Patch is against CVS version 1.6 of listconffiles.

I also got rid of a few bits of commented code, while I was at it.


Anyway, people using spaces in filenames should be neutered.

Pf


--- listconffiles-1.6	2004-06-02 14:25:35.000000000 +0200
+++ listconffiles-1.6.1	2004-06-02 15:41:06.000000000 +0200
@@ -8,6 +8,10 @@
 # Updates:
 # 20040119 - Added option '-V' to include vhosts too. Must be first argument.
 # 20040120 - Added support for spaces in filenames.
+# 20040602 - Ignore multiple spaces before filename. Properly get rid of
+#            comments on same line as valid command, and of spaces at 
+#            end of line. Spaces in filenames are evil. Don't let your 
+#            friend use them.
 #
 
 use warnings;
@@ -67,6 +71,13 @@
 
     chomp;
 
+# get rid of comments on the same line, if any.
+#        (are they allowed by apache syntax? )
+    s/(.*?)\s*#.*/$1/;
+
+# get rid of spaces at end of line
+    s/\s*$//;
+
 # If '-V' was given, we won't skip virtualhosts here.
     unless ( $withvhosts ) {
 
@@ -83,10 +94,9 @@
     }
 
 # This takes care of possible multiple serverroot instances. 
-# By specifying fields in split we allow for filename containing spaces.
     if (/^\s*serverroot/i) {
-      s/^\s*(.*)/$1/;
-      (undef,$serverroot) = split (/\s/,$_,2);
+      s/^\s*(\w+)\s*(.*)/$1 $2/; 
+      $serverroot = $2;
 
 # take away surrounding ' and "
       $serverroot =~ s/[\"\']//g;
@@ -96,8 +106,8 @@
 
 # Build the full path for the included file.
     if (/^\s*include/i) {
-      s/^\s*(.*)/$1/;
-      my (undef,$file) = split (/\s/,$_,2);
+      s/^\s*(\w+)\s*(.*)/$1 $2/; 
+      my $file = $2;
 
 # take away surrounding ' and "
       $file =~ s/[\"\']//g;
@@ -106,13 +116,6 @@
 	$file = $serverroot . $file;
       }
 
-# put back surrounding " only if needed:
-#      if ($file =~ /\s/) {
-#	$file = "\"$file\"";
-#      }
-
-#      print "DEBUG: filename = $file\n";
-
 # Follow the include.
       testfile($file);
     }



Attachment: listconffiles-1.6.1
Description: Binary data




-- 

-------------------------------------------------------------------------------
 Pierfrancesco Caci | ik5pvx | mailto:p.caci@tin.it  -  http://gusp.dyndns.org
  Firenze - Italia  | Office for the Complication of Otherwise Simple Affairs 
     Linux penny 2.6.6-rc2-mm1 #1 Sat Apr 24 17:20:00 CEST 2004 i686 GNU/Linux


Reply to: