r1029 - in packages/libapache-configfile-perl/trunk: . debian

Gunnar Wolf gwolf@costa.debian.org
Thu, 19 May 2005 16:02:06 +0000


Author: gwolf
Date: 2005-05-19 16:02:05 +0000 (Thu, 19 May 2005)
New Revision: 1029

Modified:
   packages/libapache-configfile-perl/trunk/ConfigFile.pm
   packages/libapache-configfile-perl/trunk/debian/changelog
Log:
Correctly handle lines continued with a trailing backslash


Modified: packages/libapache-configfile-perl/trunk/ConfigFile.pm
===================================================================
--- packages/libapache-configfile-perl/trunk/ConfigFile.pm	2005-05-18 04:44:35 UTC (rev 1028)
+++ packages/libapache-configfile-perl/trunk/ConfigFile.pm	2005-05-19 16:02:05 UTC (rev 1029)
@@ -212,15 +212,28 @@
     my $cmd_context = $conf;
     my @parselevel = ();
     my $line = 0;
+    my $cont_confline = '';
 
-    foreach (@conf) {
+    foreach my $confline (@conf) {
         $line++;
 
+	# Handle line continuation when a trailing \ is found
+	if ($cont_confline) {
+	    # This line is a continuation
+	    $confline = "$cont_confline $confline";
+	    $cont_confline = '';
+	} 
+	if ($confline =~ /^(.+)\\\s*$/) {
+	    # This line continues in the next one
+	    $cont_confline = $1;
+	    next;
+	}
+
         # Strip newlines/comments
-        s/\s*#.*//;
+        $confline =~ s/\s*#.*//;
 
         # If nothing's left, continue
-        next unless $_;
+        next unless $confline;
 
         # This substitutes in re-used variable on the right side of the file
         # We have to handle the ignore_case flag hence the expression
@@ -228,17 +241,17 @@
         # are visible for re-substitution
         if ($self->{expand_vars}) { 
             local($^W) = 0 ;
-            s#\$\{?(\w+)\}?#my $k =  $self->_fixcase($1);$conf->{$k}#eg;
+            $confline =~ s#\$\{?(\w+)\}?#my $k =  $self->_fixcase($1);$conf->{$k}#eg;
         }
 
         # This may be a <stuff> junk </stuff>, in which case we need
         # to nest our data struct!
-        if (m#^\s*</(\S+)\s*>\s*$#) {
+        if ($confline =~ m#^\s*</(\S+)\s*>\s*$#) {
             # match </close> - walk up
             $cmd_context = pop @parselevel;
             $self->_error("$file line $line: Mismatched closing tag '$1'") unless $cmd_context;
             next;
-        } elsif (m#^\s*<(\S+)\s*(["']*)(.*)\2>\s*$#) {
+        } elsif ($confline =~ m#^\s*<(\S+)\s*(["']*)(.*)\2>\s*$#) {
             # create new sublevel in parsing
             my $k = $self->_fixcase($1);
             push @parselevel, $cmd_context;
@@ -261,8 +274,8 @@
 
         # Split up the key and the value. The @val regexp code dynamically
         # differentiates between "space strings" and array, values.
-        my($key, $r) = m!^\s*\s*(\w+)\s*(?=\s+)(.*)!;             # split up key
-        my(@val)     = $r =~ m!\s+(?:"([^"]*[^\\])"|([^\s,]+))\n?!g;   # split up val
+        my($key, $r) = $confline =~ m!^\s*\s*(\w+)\s*(?=\s+)(.*)!;             # split up key
+        my(@val)     = $r =~ m!\s+(?:\"([^\"]*[^\\])\"|([^\s,]+))\n?!g;   # split up val
         @val = grep { defined } @val;                             # lose undef values
 
         # Check for "on/off" or "true/false" or "yes/no"

Modified: packages/libapache-configfile-perl/trunk/debian/changelog
===================================================================
--- packages/libapache-configfile-perl/trunk/debian/changelog	2005-05-18 04:44:35 UTC (rev 1028)
+++ packages/libapache-configfile-perl/trunk/debian/changelog	2005-05-19 16:02:05 UTC (rev 1029)
@@ -1,3 +1,10 @@
+libapache-configfile-perl (1.18-4) unstable; urgency=low
+
+  * Fixed: Handles lines broken by backslashes correctly. (Closes:
+    #309721)
+
+ -- Gunnar Wolf <gwolf@debian.org>  Thu, 19 May 2005 10:56:04 -0500
+
 libapache-configfile-perl (1.18-3) unstable; urgency=low
 
   * New maintainer: Debian Perl Group <pkg-perl-