perl/modules/W3C/LogValidator/lib/W3C/LogValidator HTMLValidator.pm,1.25,1.26

Update of /sources/public/perl/modules/W3C/LogValidator/lib/W3C/LogValidator
In directory hutz:/tmp/cvs-serv8818

Modified Files:
	HTMLValidator.pm 
Log Message:
* adding an option in HTML Validator module to check URIs without file extension
* fixing bugs where not all checked URIs would be reported as requested

Index: HTMLValidator.pm
===================================================================
RCS file: /sources/public/perl/modules/W3C/LogValidator/lib/W3C/LogValidator/HTMLValidator.pm,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- HTMLValidator.pm	6 Sep 2007 06:23:46 -0000	1.25
+++ HTMLValidator.pm	7 Sep 2007 05:44:36 -0000	1.26
@@ -55,6 +55,7 @@
 	$config{ShowInvalid} = "Yes" if (!exists $config{ShowInvalid});
 	$config{ShowAborted} = "No" if (!exists $config{ShowAborted});
 	$config{ShowValid} = "No" if (!exists $config{ShowValid});
+	$config{CheckExtensionlessURIs} = "No" if (!exists $config{CheckExtensionlessURIs});
 
 
 	if (exists $config{verbose}) {$verbose = $config{verbose}}
@@ -166,7 +167,7 @@
                 elsif ( $self->HEAD_check($uri) ) { $match = 1; }
                 foreach my $ext (@authorized_extensions)
                 {   
-                    if ($ext eq $uri_ext) { $match = 1; }
+                    if (($ext eq $uri_ext) or ($ext eq "*")) { $match = 1; }
                 }
 		if ($match)
 		{
@@ -183,9 +184,11 @@
 
 		  }
                 }
-		
-                push @trimmed_uris,$uri if ($match);
+            elsif (($uri_ext eq "") and $config{CheckExtensionlessURIs}) {$match = 1; } 
+            # we keep URIs without extension, if asked to
+            push @trimmed_uris,$uri if ($match);
         }
+        print "trimmed list to ", scalar @trimmed_uris. " URIs\n";
         return @trimmed_uris;
 }
 
@@ -214,6 +217,7 @@
 		@uris = $self->uris();
 		foreach my $uri (@uris) { $hits{$uri} = 0 }
 	}
+	print "processing ", scalar @uris, " URIs\n" if ($verbose >= 1);
 	print "\n (This may take a long time if you have many files to validate)\n" if ($verbose eq 1);
 	print "\n" if ($verbose > 2); # trying to breathe in the debug volume...
 	use LWP::UserAgent;
@@ -280,38 +284,37 @@
 			$self->valid($response->header('X-W3C-Validator-Status'));
 			$self->valid_err_num($response->header('X-W3C-Validator-Errors'));
 			# we know the validator has been able to (in)validate if $self->valid is not NULL
-			if ( ($self->valid) and ($self->valid_err_num) ) # invalid doc
-#			if (1) # debug
+			if ( ($self->valid)) # we got an answer about validation (valid, invalid or abort)
 			{
-			    if ( (($self->valid =~ /Invalid/i) and ($config{ShowInvalid} eq "Yes")) or (($self->valid =~ /Valid/i) and ($config{ShowValid} eq "Yes")) )  {
+			    if ( 
+			      (($self->valid =~ /Invalid/i) and ($config{ShowInvalid} eq "Yes")) 
+			      or (($self->valid =~ /Valid/i) and ($config{ShowValid} eq "Yes")) 
+			      or (($self->valid =~ /Abort/i) and ($config{ShowAborted} eq "Yes"))
+			      )  {
 				my @result_tmp;
 				push @result_tmp, $total_census;
 				push @result_tmp, $hits{$uri_orig};
-				push @result_tmp, $self->valid_err_num;
+				if ($self->valid =~ /Abort/i) {
+          push @result_tmp, "Abort";
+				}
+				else {
+				  push @result_tmp, $self->valid_err_num;
+				}
 				push @result_tmp, $uri_orig;
 				push @result, [@result_tmp];
 				$invalid_census++;
 				$last_invalid_position = $total_census;
 			    }
 			}
-			elsif (($self->valid =~ /Abort/i) and ($config{ShowAborted} eq "Yes")) {
-			  my @result_tmp;
-				push @result_tmp, $total_census;
-				push @result_tmp, $hits{$uri_orig};
-				push @result_tmp, "Abort";
-				push @result_tmp, $uri_orig;
-				push @result, [@result_tmp];
-				$invalid_census++;
-				$last_invalid_position = $total_census;
-			}
+			
 			printf (" %s!", $self->valid) if ( ($verbose > 1) and (defined ($self->valid)));
-			print " Could not validate!" if (($verbose > 1) and(!defined ($self->valid)));
+			print " Could not validate (validation failed)!" if (($verbose > 1) and(!defined ($self->valid)));
 
 			if (($verbose > 1) and ($self->valid_err_num)) # verbose or debug
 				{printf ", %s errors!",$self->valid_err_num}
 		}
 		else { 
-		  print " Could not validate!" if ($verbose > 1) ;
+		  print " Could not validate (no response from validator)!" if ($verbose > 1) ;
 		  if ($config{ShowAborted} eq "Yes") {
 			  my @result_tmp;
 				push @result_tmp, $total_census;

Received on Friday, 7 September 2007 05:44:50 UTC