Control: tag -1 pending

On Wed, Nov 07, 2012 at 04:20:01PM +0100, Stefan Bühler wrote:
> Hi,
> 
> I think you're right - the spaces in the filenames lead to problems:

That might be true. I did not consider spaces in filenames an
important problem, as they are highly unlikely to appear in
source code in a way that causes problems. You would need to
have two files:

        A
        A B

where A and B are words. Only then a problem can occur which
causes dh_autoreconf_clean to delete A.


> 
> dh_autoreconf_clean uses the perl "split" function to split the
> lines into checksum and filename:
> 
> * a comment says the delimiter is "comma", which is wrong: there are
> two spaces between checksum and filename

Yes. Totally wrong. Don't know why I wrote this.

> * split splits by default at /\s+/ - and returns as many components it finds
> 
> Fix it by replacing *both* split calls with:
> 
> my ($checksum, $filename) = split(/\s+/, $_, 2);
> 
> It uses the same delimiter, but only splits at the first one
> (returning at most two parts).

The default delimiter is the space character ' ', not
a regular expression according to perldoc. The only
difference is whether leading spaces are ignored
or not. But, let's use split(' ', $_, 2) to be as
close as possible.

Fixed in git.


-- 
Julian Andres Klode  - Debian Developer, Ubuntu Member

See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.
From 1c7541cbb3bbe08841ef063abc01147d69fa8224 Mon Sep 17 00:00:00 2001
From: Julian Andres Klode <j...@debian.org>
Date: Wed, 7 Nov 2012 16:38:26 +0100
Subject: [PATCH] dh_autoreconf_clean: Correctly handle spaces in file names
 (Closes: #692317)

We split the checksums and filenames by simply using split, causing
us to ignore any part of the filename after a space. Limit the split
to split the line into two fields only.

This bug does not affect most projects, even if they have spaces
in their file names. It only affects projects where two files
in the same directory have a common prefix followed by a space,
and one of the files is modified (or the order they are visited
in changed).
---
 dh_autoreconf_clean |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dh_autoreconf_clean b/dh_autoreconf_clean
index 8d399d9..d05b9a5 100755
--- a/dh_autoreconf_clean
+++ b/dh_autoreconf_clean
@@ -44,7 +44,7 @@ open(FILE, 'debian/autoreconf.before') or die($!);
 while(<FILE>) {
     chomp($_);
     # The delimiter here is a comma
-    my ($checksum, $filename) = split;
+    my ($checksum, $filename) = split(' ', $_, 2);
     # Put the key => value pair in the hash
     $file{$filename} = $checksum;
 }
@@ -56,7 +56,7 @@ open(FILE, 'debian/autoreconf.after') or die($!);
 my $ltcheck = "";
 while(<FILE>) {
     chomp($_);
-    my ($checksum, $filename) = split;
+    my ($checksum, $filename) = split(' ', $_, 2);
 
     if ($filename eq "/usr/share/libtool/config/ltmain.sh") {
         $ltcheck = $checksum;
-- 
1.7.10.4

Attachment: pgpg7YWyAIE0d.pgp
Description: PGP signature

Reply via email to