On Fri, Sep 24, 2010 at 01:30:26PM -0500, Raphael Geissert wrote: > On 24 September 2010 13:20, Adam D. Barratt <a...@adam-barratt.org.uk> wrote: > > fwiw, this is trivially fixable in the watch file by stopping it being > > overly greedy; this watchfile works correctly: > > > > ftp://ftp.hylafax.org/source/hylafax-([^SNAPSHOT]*?)\.tar\.gz > > Sure, the regex could even use a negative look-ahead instead of > relying on that class. > Still, I think that uscan should be doing better here
Specifically for non-HTML responses from FTP sites, we could split the response on newlines and examine each line on its own (like the attached patch). This would prevent sloppy regexes from slurping up multiple lines. I wouldn't be comfortable doing this with the http:// watch lines or HTML responses from ftp:// watch lines though since those are more likely to not be nicely contained to a single physical line. -- James GPG Key: 1024D/61326D40 2003-09-02 James Vega <james...@debian.org>
diff --git a/scripts/uscan.pl b/scripts/uscan.pl index ec0df77..d281928 100755 --- a/scripts/uscan.pl +++ b/scripts/uscan.pl @@ -1026,22 +1026,24 @@ sub process_watchline ($$$$$$) } else { # they all look like: # info info ... info filename [ -> linkname] - while ($content =~ m/\s($filepattern)(\s+->\s+\S+)?$/mg) { - my $file = $1; - my $mangled_version = join(".", $file =~ m/^$filepattern$/); - foreach my $pat (@{$options{'uversionmangle'}}) { - if (! safe_replace(\$mangled_version, $pat)) { - warn "$progname: In $watchfile, potentially" - . " unsafe or malformed uversionmangle" - . " pattern:\n '$pat'" - . " found. Skipping watchline\n" - . " $line\n"; - return 1; + for my $ln (split(/\n/, $content)) { + if ($ln =~ m/\s($filepattern)(\s+->\s+\S+)?$/) { + my $file = $1; + my $mangled_version = join(".", $file =~ m/^$filepattern$/); + foreach my $pat (@{$options{'uversionmangle'}}) { + if (! safe_replace(\$mangled_version, $pat)) { + warn "$progname: In $watchfile, potentially" + . " unsafe or malformed uversionmangle" + . " pattern:\n '$pat'" + . " found. Skipping watchline\n" + . " $line\n"; + return 1; + } } + push @files, [$mangled_version, $file]; } - push @files, [$mangled_version, $file]; } - } + } if (@files) { if ($verbose) { @@ -1619,12 +1621,14 @@ sub newest_dir ($$$$$) { } else { # they all look like: # info info ... info filename [ -> linkname] - while ($content =~ m/($pattern)(\s+->\s+\S+)?$/mg) { - my $dir = $1; - my $mangled_version = join(".", $dir =~ m/^$pattern$/); - push @dirs, [$mangled_version, $dir]; + foreach my $ln (split(/\n/, $content)) { + if ($ln =~ m/\s($pattern)(\s+->\s+\S+)?$/) { + my $dir = $1; + my $mangled_version = join(".", $dir =~ m/^$pattern$/); + push @dirs, [$mangled_version, $dir]; + } } - } + } if (@dirs) { if ($debug) { print STDERR "-- Found the following matching dirs:\n";
signature.asc
Description: Digital signature