diff options
author | link <link@localhost> | 2002-08-22 00:56:48 +0000 |
---|---|---|
committer | link <link@localhost> | 2002-08-22 00:56:48 +0000 |
commit | 80726fd85888c16a45d1f5cd9b3637f4d346ef42 (patch) | |
tree | b5339d425961c3a787fdb4ec9c4eaccd593b8f40 | |
parent | 95d59b55cb6fe32f13d3723b985e7097241cd227 (diff) | |
download | markup-validator-80726fd85888c16a45d1f5cd9b3637f4d346ef42.zip markup-validator-80726fd85888c16a45d1f5cd9b3637f4d346ef42.tar.gz markup-validator-80726fd85888c16a45d1f5cd9b3637f4d346ef42.tar.bz2 |
Applying checklink-cleanup.patch from Ville SKytta. Thanks Ville!
(A bunch of cleanups; police whitespace, namespace, HTML, etc.)
-rwxr-xr-x | httpd/cgi-bin/checklink.pl | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/httpd/cgi-bin/checklink.pl b/httpd/cgi-bin/checklink.pl index d0d1e62..1237f06 100755 --- a/httpd/cgi-bin/checklink.pl +++ b/httpd/cgi-bin/checklink.pl @@ -1,11 +1,11 @@ -#! /usr/bin/perl -w +#!/usr/bin/perl -w # # W3C Link Checker # by Hugo Haas <hugo@w3.org> # (c) 1999-2002 World Wide Web Consortium # based on Renaud Bruyeron's checklink.pl # -# $Id: checklink.pl,v 2.91 2002-08-20 01:51:31 link Exp $ +# $Id: checklink.pl,v 2.92 2002-08-22 00:56:48 link Exp $ # # This program is licensed under the W3C(r) License: # http://www.w3.org/Consortium/Legal/copyright-software @@ -38,7 +38,7 @@ $| = 1; # Version info my $PROGRAM = 'W3C checklink'; -my $VERSION = q$Revision: 2.91 $ . '(c) 1999-2002 W3C'; +my $VERSION = q$Revision: 2.92 $ . '(c) 1999-2002 W3C'; my $REVISION; ($REVISION = $VERSION) =~ s/Revision: (\d+\.\d+) .*/$1/; # Different options specified by the user @@ -126,7 +126,7 @@ if ($#ARGV >= 0 && !(@ARGV == 1 && $ARGV[0] eq 'DEBUG')) { } } - use CGI; + use CGI (); use CGI::Carp qw(fatalsToBrowser); $query = new CGI; # Set a few parameters in CGI mode @@ -294,7 +294,7 @@ Options: for example, it would be: http://www.w3.org/TR/html4/ -n/--noacclanguage Do not send an Accept-Language header. - -L/--languages Languages accepted (default: '$_languages'). + -L/--languages Languages accepted (default: '$_languages'). -q/--quiet No output if no errors are found. -v/--verbose Verbose mode. -i/--indicator Show progress while parsing. @@ -323,7 +323,7 @@ Please send bug reports and comments to the www-validator mailing list: sub ask_password() { print(STDERR 'Enter the password for user '.$_user.': '); - # Will only work on Unix... + # Will only work on Unix... Term::ReadKey from CPAN would be better. system('stty -echo'); chomp($_password = <STDIN>); system('stty echo'); @@ -337,7 +337,7 @@ sub ask_password() { ########################################### sub urize() { - use URI; + use URI (); $_ = URI::Escape::uri_unescape($_[0]); my $base; my $res = $_; @@ -397,7 +397,7 @@ sub check_uri() { if ($_html) { print("</h2>\n"); if (! $_summary) { - use URI; + use URI::Escape (); printf("<p>Go to <a href='#%s'>the results</a>.</p>\n", $result_anchor); printf("<p>Check also: @@ -415,7 +415,7 @@ Validity</a></p> $processed{$absolute_uri} = 1; # Parse the document my $p = &parse_document($uri, $absolute_uri, - $response->content(), 1, + $response->content(), 1, $depth != 0); my $base = URI->new($p->{base}); @@ -711,7 +711,7 @@ sub W3C::UserAgent::simple_request() { sub W3C::UserAgent::redirect_ok { my ($self, $request) = @_; - + if (! ($_summary || (!$doc_count && $_html))) { &hprintf("\n%s %s ", $request->method(), $request->uri()); } @@ -797,7 +797,7 @@ sub get_uri() { print "\n"; } return &get_uri($method, $response->request->url, - $start, $ua->{Redirects}, + $start, $ua->{Redirects}, $code, $realm, $message, 1); } # Record the redirects @@ -1099,7 +1099,6 @@ sub W3C::CheckLink::declaration() { ################################ sub check_validity() { - use HTTP::Status; my ($testing, $uri, $links, $redirects) = @_; # $testing is the URI of the document checked # $uri is the URI of the target that we are verifying @@ -1185,10 +1184,10 @@ sub check_validity() { } sub escape_match($, \%) { - use URI::Escape; - my ($a, $hash) = (uri_unescape($_[0]), $_[1]); + use URI::Escape (); + my ($a, $hash) = (URI::Escape::uri_unescape($_[0]), $_[1]); foreach $b (keys %$hash) { - if ($a eq uri_unescape($b)) { + if ($a eq URI::Escape::uri_unescape($b)) { return(1); } } @@ -1203,15 +1202,15 @@ sub authentication() { my $r = $_[0]; $r->headers->www_authenticate =~ /Basic realm=\"([^\"]+)\"/; my $realm = $1; - my $authHeader = $r->headers->www_authenticate; + my $authHeader = $r->headers->www_authenticate; if ($_cl) { printf(STDERR "\nAuthentication is required for %s.\n", $r->request->url); printf(STDERR "The realm is %s.\n", $realm); print(STDERR "Use the -u and -p options to specify a username and password.\n"); } else { - printf("Status: 401 Authorization Required\nWWW-Authenticate: %s\nConnection: close\nContent-Type: text/html\n\n", $r->headers->www_authenticate); + printf("Status: 401 Authorization Required\nWWW-Authenticate: %s\nConnection: close\nContent-Language: en\nContent-Type: text/html\n\n", $r->headers->www_authenticate); printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> -<html> +<html lang=\"en\"> <head> <title>401 Authorization Required</title> </head> @@ -1229,7 +1228,7 @@ sub authentication() { ################## sub get_timestamp() { - use Time::HiRes; + use Time::HiRes (); return pack('LL', Time::HiRes::gettimeofday()); } @@ -1381,7 +1380,7 @@ sub show_link_report { $whattodo = 'You must change this link: people using a browser without Javascript support will <em>not</em> be able to follow this link. See the -<a href="http://www.w3.org/TR/1999/WAI-WEBCONTENT-19990505/#tech-scripts">Web +<a href="http://www.w3.org/TR/1999/WAI-WEBCONTENT-19990505/#tech-scripts">Web Content Accessibility Guidelines on the use of scripting on the Web</a> and the <a href="http://www.w3.org/TR/WCAG10-HTML-TECHS/#directly-accessible-scripts">techniques @@ -1431,7 +1430,7 @@ on how to solve this</a>.'; } printf(" <dt%s>%s</dt> -<dd>What to do: <strong%s>%s</strong>%s<br> +<dd>What to do: <strong%s>%s</strong>%s<br></dd> <dd>HTTP Code returned: %d%s<br> HTTP Message: %s%s%s</dd> <dd>Lines: %s</dd>\n", @@ -1461,7 +1460,7 @@ HTTP Message: %s%s%s</dd> # HTTP original message defined($results->{$u}{location}{orig_message}) ? &encode($results->{$u}{location}{orig_message}). - ' <span title="redirected to">-></span> ' + ' <span title="redirected to">-></span> ' : '', # HTTP final message $http_message, @@ -1526,7 +1525,7 @@ HTTP Message: %s%s%s</dd> } } } - # End of the table + # End of the table if ($_html) { print("</dl>\n"); } @@ -1643,7 +1642,7 @@ sub links_summary { print('</h3><p><i>Fragments listed are broken. See the table below to know what action to take.</i></p>'); # Print a summary - print "<table border=\"1\">\n<tr><td><b>Code</b></td><td><b>Occurences</b></td><td><b>What to do</b></td></tr>\n"; + print "<table border=\"1\">\n<tr><td><b>Code</b></td><td><b>Occurrences</b></td><td><b>What to do</b></td></tr>\n"; my $code; foreach $code (sort(keys(%code_summary))) { printf('<tr%s>', &bgcolor($code)); @@ -1685,7 +1684,7 @@ sub global_stats() { my $stop = &get_timestamp(); return sprintf("Checked %d document(s) in %ss.", ($doc_count<=$_max_documents? $doc_count : $_max_documents), - &time_diff($timestamp, $stop)); + &time_diff($timestamp, $stop)); } ################## @@ -1705,7 +1704,7 @@ sub html_header() { print " <!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> -<html> +<html lang=\"en\"> <head> <title>W3C".$title."</title> <style type=\"text/css\"> @@ -1716,8 +1715,8 @@ body { background: white; } -pre { - font-family: monospace +pre, code, tt { + font-family: monospace; } img { @@ -1752,7 +1751,7 @@ dt.report { </style> </head> <body> -<a href=\"http://www.w3.org/\"><img alt=\"W3C\" src=\"http://www.w3.org/Icons/w3c_home\" height=\"48\" width=\"72\"></a> +<p><a href=\"http://www.w3.org/\" title=\"W3C\"><img alt=\"W3C\" src=\"http://www.w3.org/Icons/w3c_home\" height=\"48\" width=\"72\"></a></p> <h1>W3C<sup>®</sup>".$title."</h1> \n"; } @@ -1805,9 +1804,8 @@ Check out the <a href=\"http://www.w3.org/2000/07/checklink\">documentation</a>. Download the <a href=\"http://dev.w3.org/cvsweb/~checkout~/validator/httpd/cgi-bin/checklink.pl?rev=".$REVISION."&content-type=text/plain\">source -code</a> from the -<a href=\"http://dev.w3.org/cvsweb/validator/httpd/cgi-bin/checklink.pl\">CVS -log</a>. +code</a> from +<a href=\"http://dev.w3.org/cvsweb/validator/httpd/cgi-bin/checklink.pl\">CVS</a>. </address> </body> </html> @@ -1828,22 +1826,22 @@ sub print_form() { my ($q) = @_; &html_header('', 1); print "<form action=\"".$q->self_url()."\" method=\"get\"> -<p>Enter the address (<a href='http://www.w3.org/Addressing/#terms'>URL</a>) -of a document that you would like to check:</p> -<p><input type=\"text\" size=\"50\" name=\"uri\"></p> +<p><label for=\"uri\">Enter the address (<a href='http://www.w3.org/Addressing/#terms'>URL</a>) +of a document that you would like to check:</label></p> +<p><input type=\"text\" size=\"50\" id=\"uri\" name=\"uri\"></p> <p>Options:</p> <p> - <input type=\"checkbox\" name=\"summary\"> Summary only + <label><input type=\"checkbox\" name=\"summary\"> Summary only</label> <br> - <input type=\"checkbox\" name=\"hide_redirects\"> Hide redirects + <label><input type=\"checkbox\" name=\"hide_redirects\"> Hide redirects</label> <br> - <input type=\"checkbox\" name=\"no_accept_language\"> Don't send <tt>Accept-Language</tt> headers. + <label><input type=\"checkbox\" name=\"no_accept_language\"> Don't send <tt>Accept-Language</tt> headers</label> <br> - <input type=\"checkbox\" name=\"hide_dir_redirects\"> Hide directory redirects + <label><input type=\"checkbox\" name=\"hide_dir_redirects\"> Hide directory redirects</label> <br> - <input type=\"checkbox\" name=\"recursive\"> Check linked documents recursively <small>(maximum: $_max_documents documents; sleeping $_sleep_time seconds between each document)</small> + <label><input type=\"checkbox\" name=\"recursive\"> Check linked documents recursively <small>(maximum: $_max_documents documents; sleeping $_sleep_time seconds between each document)</small></label> <br> - Depth of the recursion: <input type=\"text\" size=\"3\" name=\"depth\"><small>(-1 is the default and means unlimited)</small> + <label>Depth of the recursion: <input type=\"text\" size=\"3\" name=\"depth\"><small>(-1 is the default and means unlimited)</small></label> </p> <p><input type=\"submit\" name=\"submit\" value=\"Check\"></p> </form> |