Index: check
===================================================================
RCS file: /home/cvs/W3C/validator/httpd/cgi-bin/check,v
retrieving revision 1.1.1.2
retrieving revision 1.5
diff -r1.1.1.2 -r1.5
13d12
< use LWP::UserAgent;
14a14,16
> use LWP::UserAgent;
> use URI::Escape;
> use CGI qw(:cgi -newstyle_urls -private_tempfiles);
45,46c47
< my ( $uri,
<     $validity, $version, $document_type, $xmlflags, %FORM, %undef_frag,
---
> my ($validity, $version, $document_type, $xmlflags, %undef_frag,
51c52
<     $pedantic_blurb, $level, $prevlevel, $i, $prevdata );
---
>     $pedantic_blurb, $level, $prevlevel, $i, $prevdata);
58,59c59
< my $html32_doctype	=
< 			qq{<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">};
---
> my $html32_doctype	= qq{<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">};
167,175c167,191
< # accept either check/foo or check?foo
< my $parameters = $ENV{PATH_INFO} || $ENV{QUERY_STRING};
< 
< if ( ! $parameters ) {
<     &redirect_to_home_page;
< }
< 
< my $pair;
< foreach $pair (split(/[&;,]/, $parameters)) {
---
> #
> # Create a new CGI object.
> my $q = new CGI;
> 
> #
> # Futz the URI so "/referer" works.
> if ($q->path_info eq '/referer') {
>   $q->param('uri', $q->referer);
> }
> 
> #
> # Use "url" unless a "uri" was also given.
> if ($q->param('url') and not $q->param('uri')) {
>   $q->param('uri', $q->param('url'));
> }
> 
> #
> # Send them to the homepage unless we can extract a URI from either of the
> # acceptable sources: uri, url or /referer.
> &redirect_to_home_page unless $q->param('uri');
> 
> #
> # Munge the URI to include commonly omitted prefixes/suffixes.
> $q->param('uri', $q->param('uri') . '/')   unless $q->param('uri') =~ m(/);
> $q->param('uri', 'http://' . $q->param('uri')) if $q->param('uri') =~ m(^www)i;
177,207d192
<     # this referer handling probably needs fixing to handle strange cases
<     # (possibly tied to the explanation given when connections fail;
<     # the referer could be on an intranet, etc.)
< 
<     if ( $pair eq "/referer" && $ENV{HTTP_REFERER} =~ m,^http://, ) {
< 	$FORM{uri} = $ENV{HTTP_REFERER};
< 	next;
<     }
< 
<     my ($name, $value) = split(/=/, $pair);
<     $value =~ tr/+/ /;
<     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
< 
<     $FORM{$name} = $value || "true";
< }
< 
< # accept "url=foo" for backwards compatibility (but uri=foo is preferred)
< $uri = URI::URL->new($FORM{uri} || $FORM{url});
< 
< if ( ( $uri eq "true" || length( $uri ) == 0 ) &&
<         ( $ENV{REQUEST_URI} =~ /check/ ) ) {
<     &redirect_to_home_page;
< }
< 
< if ( $uri !~ /\// ) {
<     $uri .= "/";
< }
< 
< if ( $uri =~ /^www/i ) {
<     $uri = "http://$uri";
< }
217c202,206
< <html>
---
> <HTML>
>   <HEAD>
>     <TITLE>W3C HTML Validation Service Results</TITLE>
>     <LINK rev="made" href="mailto:$maintainer">
>   </HEAD>
219,232c208,209
<   <head>
<     <title>W3C HTML Validation Service Results</title>
<     <link rev="made" href="mailto:$maintainer">
<   </head>
< 
<   <body bgcolor="#FFFFFF" text="#000000" link="#0000ee" vlink="#551a8b">
< 
<   <p>
<     <a href="http://www.w3.org/"><img
<        src="http://www.w3.org/Icons/WWW/w3c_home" height=48 border=0
<        alt="W3C"></a>
<   </p>
< 
<   <h1><a href="/">W3C HTML Validation Service</a> Results</h1>
---
>   <BODY bgcolor="#FFFFFF" text="#000000" link="#0000ee" vlink="#551a8b">
>   <H1><A href="http://www.w3.org/"><IMG src="http://www.w3.org/Icons/WWW/w3c_home" border=0 height=48 width=72 alt="W3C"></A> <A href="$abs_svc_uri">HTML Validation Service</A> Results</H1>
237c214
< if ( $uri !~ m#^http://# ) {
---
> unless($q->param('uri') =~ m(^http://)) {
265c242
< my $request = new HTTP::Request(GET => $uri);
---
> my $request = new HTTP::Request(GET => $q->param('uri'));
277d253
<     my $optionstring = &build_options;
287,288c263,264
< 	&print_unknown_http_error_message( $uri, $response->code,
< 	    $response->message );
---
> 	&print_unknown_http_error_message($q->param('uri'), $response->code,
> 	    $response->message);
307c283
<   Sorry, I can't validate this document because its returned
---
>   Sorry, I am unable to validate this document because its returned
377c353,354
< print qq{<ul>\n  <li><a href="$uri_def_uri">URI</a>: <a href="$uri">$uri</a>\n};
---
> print qq(<ul>\n  <li><a href="$uri_def_uri">URI</a>: ),
>   '<a href="', $q->param('uri'), '">', $q->param('uri'), qq(</a>\n);
497c474
<     on Aug 31, 1999, but it isn't quite working yet; stay tuned to <a
---
>     on Aug 31, 1999, but is not quite working yet; stay tuned to <a
500c477
<     please don't trust this service's output for XML documents
---
>     please do not trust this service\'s output for XML documents
707c684
<     To show your readers that you've taken the care to create an
---
>     To show your readers that you have taken the care to create an
730,735c707,708
<     my $escaped_uri = $uri;
<     $escaped_uri =~  s/=/%3D/g;
<     $escaped_uri =~ s/\&/%26/g;
<     $escaped_uri =~  s/;/%3B/g;
<     $escaped_uri =~  s/,/%2C/g;
< 	# ugh
---
>     my $escaped_uri = uri_escape $q->param('uri');
>     my $thispage    = $q->self_url;
737,738d709
<     my $thispage = "${abs_svc_uri}check?uri=$escaped_uri";
<     $thispage .= &build_options;
760,770c731,737
< my $validation_return_code = $?;
< 
< if ( $FORM{"weblint"} eq "true" ) {
< 
<     if ( $FORM{"pw"} eq "true" ) {
< 	$pedanticflags = "-pedantic -e mailto-link";
< 	$pedantic_blurb = " (in \"pedantic\" mode)";
<     }
<     else {
< 	$pedanticflags = "";
<     }
---
> if (defined $q->param('weblint')) {
>   if (defined $q->param('pw')) {
>     $pedanticflags  = '-pedantic -e mailto-link';
>     $pedantic_blurb = ' (in "pedantic" mode)';
>   } else {
>     $pedanticflags = '';
>   }
815c782
< if ( $FORM{"outline"} eq "true" ) {
---
> if (defined $q->param('outline')) {
868c835
<       If this doesn't look like a real outline, it is likely that the
---
>       If this does not look like a real outline, it is likely that the
876c843
< if ( $FORM{"ss"} eq "true" ) {
---
> if (defined $q->param('ss')) {
901c868
< if ( $FORM{"sp"} eq "true" ) {
---
> if (defined $q->param('sp')) {
908c875
<     still under construction! I'm trying to make this easier to read
---
>     still under construction! I am trying to make this easier to read
912c879
<     if ( $FORM{"noatt"} ne "true" ) {
---
>     unless (defined $q->param('noatt')) {
920,921c887,888
<     if ( $FORM{"noatt"} eq "true" ) {
< 	print <<'EOF';
---
>     if (defined $q->param('noatt')) {
>       print <<'EOF';
923c890
<       I'm excluding the attributes, as you requested.
---
>       I am excluding the attributes, as you requested.
931,935c898,902
< 	if ( $FORM{"noatt"} eq "true" ) {
< 	    next if /^A/;
< 	    next if /^\(A$/;
< 	    next if /^\)A$/;
< 	}
---
>       if (defined $q->param('noatt')) {
> 	next if /^A/;
> 	next if /^\(A$/;
> 	next if /^\)A$/;
>       }
937c904
< # experimental: skip data if it's only newlines and space.
---
> # experimental: skip data if it is only newlines and space.
1043,1053d1009
< sub build_options {
< 
<     my $optionstring = "";
<     my $option;
<     foreach $option (@options) {
<         $optionstring .= ";$option" if $FORM{$option} eq "true";
<     }
<     return $optionstring;
< 
< }
< 
1055,1059c1011,1013
< 
<     unlink $temp;
<     unlink "$temp.esis";
<     unlink "$temp.weblint";
< 
---
>   unlink $temp           or warn "unlink($temp) returned: $!\n";
>   unlink "$temp.esis"    or warn "unlink($temp.esis) returned: $!\n";
>   unlink "$temp.weblint" or warn "unlink($temp.weblint) returned: $!\n";
1067c1021
<     print LOG "$ENV{REMOTE_HOST}\t$validity $version\t$uri\n";
---
>     print LOG "$ENV{REMOTE_HOST}\t$validity $version\t", $q->param('uri'), "\n";
1103,1106c1057,1060
<     $count++ if $FORM{ss}      eq "true";
<     $count++ if $FORM{sp}      eq "true";
<     $count++ if $FORM{weblint} eq "true";
<     $count++ if $FORM{outline} eq "true";
---
>     $count++ if defined $q->param('ss');
>     $count++ if defined $q->param('sp');
>     $count++ if defined $q->param('weblint');
>     $count++ if defined $q->param('outline');
1110c1064
< 	if ( $FORM{"weblint"} eq "true" ) {
---
> 	if (defined $q->param('weblint')) {
1116c1070
< 	if ( $FORM{"outline"} eq "true" ) {
---
> 	if (defined $q->param('outline')) {
1122c1076
< 	if ( $FORM{"ss"} eq "true" ) {
---
> 	if (defined $q->param('ss')) {
1128c1082
< 	if ( $FORM{"sp"} eq "true" ) {
---
> 	if (defined $q->param('sp')) {
