W3C home > Mailing lists > Public > www-validator-cvs@w3.org > August 2010

link-checker commit: Make forbidden protocols configurable (#29).

From: Mercurial notifier <nobody@w3.org>
Date: Thu, 05 Aug 2010 14:47:27 +0000
To: link-checker updates <www-validator-cvs@w3.org>
Message-Id: <E1Oh1jD-0006Pr-0J@blinky.w3.org>
changeset:   361:8aee47762a31
user:        ville
date:        Thu Mar 11 17:54:33 2010 +0000
files:       NEWS bin/checklink etc/checklink.conf
description:
Make forbidden protocols configurable (#29).


diff -r 132872da47d3 -r 8aee47762a31 NEWS
--- a/NEWS	Thu Mar 11 17:13:42 2010 +0000
+++ b/NEWS	Thu Mar 11 17:54:33 2010 +0000
@@ -10,6 +10,7 @@
 - Improved heuristics when passed non-absolute URLs.
 - Support for cookies (command line only for now).
 - More "false positive" failure avoidance efforts for "make test".
+- The set of forbidden protocols is now configurable.
 - New dependencies: CSS-DOM >= 0.09.
 - Updated dependencies: Perl >= 5.8.
 
diff -r 132872da47d3 -r 8aee47762a31 bin/checklink
--- a/bin/checklink	Thu Mar 11 17:13:42 2010 +0000
+++ b/bin/checklink	Thu Mar 11 17:54:33 2010 +0000
@@ -5,7 +5,7 @@
 # (c) 1999-2010 World Wide Web Consortium
 # based on Renaud Bruyeron's checklink.pl
 #
-# $Id: checklink,v 4.192 2010-03-11 17:13:42 ville Exp $
+# $Id: checklink,v 4.193 2010-03-11 17:54:32 ville Exp $
 #
 # This program is licensed under the W3C(r) Software License:
 #       http://www.w3.org/Consortium/Legal/copyright-software
@@ -91,7 +91,6 @@
 
     $self->allow_private_ips(1);
 
-    # TODO: bug 29
     $self->protocols_forbidden([qw(mailto javascript)]);
 
     return $self;
@@ -306,7 +305,7 @@
     $PROGRAM  = 'W3C-checklink';
     $VERSION  = '4.5';
     $REVISION = sprintf('version %s (c) 1999-2010 W3C', $VERSION);
-    my ($cvsver) = q$Revision: 4.192 $ =~ /(\d+[\d\.]*\.\d+)/;
+    my ($cvsver) = q$Revision: 4.193 $ =~ /(\d+[\d\.]*\.\d+)/;
     $AGENT = sprintf(
         '%s/%s [%s] %s',
         $PROGRAM, $VERSION, $cvsver,
@@ -502,6 +501,13 @@
 EOF
 }
 
+# Add configured forbidden protocols
+if ($Cfg{Forbidden_Protocols}) {
+    my $forbidden = $ua->protocols_forbidden();
+    push(@$forbidden, split(/[,\s]+/, lc($Cfg{Forbidden_Protocols})));
+    $ua->protocols_forbidden($forbidden);
+}
+
 if ($Opts{Command_Line}) {
 
     require Text::Wrap;
@@ -568,7 +574,7 @@
     require CGI::Cookie;
 
     # file: URIs are not allowed in CGI mode
-    my $forbidden = $ua->protocols_forbidden() || [];
+    my $forbidden = $ua->protocols_forbidden();
     push(@$forbidden, 'file');
     $ua->protocols_forbidden($forbidden);
 
diff -r 132872da47d3 -r 8aee47762a31 etc/checklink.conf
--- a/etc/checklink.conf	Thu Mar 11 17:13:42 2010 +0000
+++ b/etc/checklink.conf	Thu Mar 11 17:54:33 2010 +0000
@@ -1,6 +1,6 @@
 #
 # Configuration file for the W3C Link Checker
-# $Id: checklink.conf,v 1.7 2009-02-10 18:36:31 ville Exp $
+# $Id: checklink.conf,v 1.8 2010-03-11 17:54:33 ville Exp $
 #
 # See Config::General(3) for the syntax; 'SplitPolicy' is 'equalsign' here.
 #
@@ -50,3 +50,13 @@
 #
 # Default:
 # Doc_URI = http://validator.w3.org/docs/checklink.html
+
+
+#
+# Forbidden_Protocols is a comma separated list of protocols/URI schemes
+# that the link checker is not allowed to use.  The javascript and mailto
+# schemes are always forbidden, and so is the file protocol when running
+# as a CGI script.
+#
+# Default:
+# Forbidden_Protocols = javascript,mailto
Received on Thursday, 5 August 2010 14:47:38 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:43 UTC