[devscripts] 01/02: uscan: Remove whitespace from URLs in more places

James McCoy jamessan at debian.org
Mon Aug 22 01:43:03 UTC 2016


This is an automated email from the git hooks/post-receive script.

jamessan pushed a commit to branch master
in repository devscripts.

commit a519065077b9777baeefc6b6054b17cd3b26437c
Author: James McCoy <jamessan at debian.org>
Date:   Sun Aug 21 20:37:30 2016 -0400

    uscan: Remove whitespace from URLs in more places
    
    Add fix_href function to centralize common cleanup of URLs.
    
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 scripts/uscan.pl | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index 6de1258..73b2d35 100755
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -2957,11 +2957,8 @@ sub process_watchline ($$$$$$)
 	while ($content =~ m/<\s*a\s+[^>]*href\s*=\s*([\"\'])(.*?)\1/sgi) {
 	    my $href = $2;
 	    my $mangled_version;
-	    # Remove whitespace from URLs:
-	    # https://www.w3.org/TR/html5/links.html#links-created-by-a-and-area-elements
 	    $href =~ s/\n//g;
-	    $href =~ s/^\s+//;
-	    $href =~ s/\s+$//;
+	    $href = fix_href($href);
 	    uscan_debug "Checking href $href\n";
 	    foreach my $_pattern (@patterns) {
 		if ($href =~ m&^$_pattern$&) {
@@ -3065,7 +3062,7 @@ sub process_watchline ($$$$$$)
 	    uscan_verbose "HTMLized FTP listing by the HTTP proxy\n";
 	    while ($content =~
 		m/(?:<\s*a\s+[^>]*href\s*=\s*\")((?-i)$pattern)\"/gi) {
-		my $file = $1;
+		my $file = fix_href($1);
 		my $mangled_version = join(".", $file =~ m/^$pattern$/);
 		foreach my $pat (@{$options{'uversionmangle'}}) {
 		    if (! safe_replace(\$mangled_version, $pat)) {
@@ -3904,7 +3901,7 @@ sub newest_dir ($$$$$) {
 	my @hrefs;
 	my $match ='';
 	while ($content =~ m/<\s*a\s+[^>]*href\s*=\s*([\"\'])(.*?)\1/gi) {
-	    my $href = $2;
+	    my $href = fix_href($2);
 	    uscan_verbose "Matching target for dirversionmangle:   $href\n";
 	    if ($href =~ m&^$dirpattern/?$&) {
 		my $mangled_version = join(".", map { $_ // '' } $href =~ m&^$dirpattern/?$&);
@@ -4426,6 +4423,18 @@ sub quoted_regex_parse($) {
     return ($parsed_ok, $regexp, $replacement, $flags);
 }
 
+sub fix_href
+{
+    my ($href) = @_;
+
+    # Remove whitespace from URLs:
+    # https://www.w3.org/TR/html5/links.html#links-created-by-a-and-area-elements
+    $href =~ s/^\s+//;
+    $href =~ s/\s+$//;
+
+    return $href;
+}
+
 sub safe_replace($$) {
     my ($in, $pat) = @_;
     eval "uscan_debug \"safe_replace input=\\\"\$\$in\\\"\\n\"";

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list