validator/httpd/cgi-bin check,1.481,1.482

Update of /sources/public/validator/httpd/cgi-bin
In directory hutz:/tmp/cvs-serv11904/httpd/cgi-bin

Modified Files:
	check 
Log Message:
more info in debug. fixing parse mode fallback for unknown document types

Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.481
retrieving revision 1.482
diff -u -d -r1.481 -r1.482
--- check	16 Mar 2007 03:20:16 -0000	1.481
+++ check	16 Mar 2007 06:56:09 -0000	1.482
@@ -654,6 +654,7 @@
                qw(no_proxy http_proxy https_proxy ftp_proxy FTP_PASSIVE)),
              { name => 'Content-Encoding',  value => $File->{ContentEnc} },
              { name => 'Content-Language', value => $File->{ContentLang} },
+             { name => 'Content-Location', value => $File->{ContentLoc} },
              { name => 'Transfer-Encoding', value => $File->{TransferEnc} },
              { name => 'Parse Mode', value => $File->{Mode} },
              { name => 'Parser', value => $parser_name },
@@ -703,8 +704,15 @@
 # check the received mime type against Allowed mime types
 if ($File->{ContentType}){
   my @allowedMediaType = split(" ", $CFG->{Types}->{$File->{DOCTYPE}}->{Types}->{Allowed});
-  my $usedCTisAllowed = FALSE;
-  foreach (@allowedMediaType) { $usedCTisAllowed = TRUE if ($_ eq $File->{ContentType}); }
+  my $usedCTisAllowed;
+  if (scalar @allowedMediaType)  {  
+    $usedCTisAllowed = FALSE;
+    foreach (@allowedMediaType) { $usedCTisAllowed = TRUE if ($_ eq $File->{ContentType}); }
+  }
+  else {
+    # wedon't know what media type is recommended, so better shut up 
+    $usedCTisAllowed = TRUE;
+  }
   if(! $usedCTisAllowed ){
     &add_warning('W23', {
         W23_type => $File->{ContentType},
@@ -1121,6 +1129,7 @@
   $File->{ContentType}     = $ct;
   $File->{ContentEnc}      = $res->content_encoding;
   $File->{ContentLang}      = $res->content_language;
+  $File->{ContentLoc}      = $res->header('Content-Location');
   $File->{TransferEnc}     = $res->header('Client-Transfer-Encoding');
   $File->{Charset}->{HTTP} = lc $charset;
   $File->{Modified}        = $lastmod;
@@ -1737,7 +1746,15 @@
 
   $mode = 'TBD' unless $mode eq 'SGML' or $mode eq 'XML';
 
-  if ($File->{Mode} ne 'TBD' and $mode ne $File->{Mode}) {
+  # if the document type is not known ($mode = TBD) 
+  # but the content-type clearly shows we should used SGML or XML ($File->{Mode} ne 'TBD')
+  # then we're happy - we use that
+  if (($mode eq 'TBD') and ($File->{Mode} ne 'TBD')) {
+    $mode = $File->{Mode};
+  }
+
+  #  if document-type recommended mode and content-type recommended mode clash
+  if (($mode ne 'TBD') and ($mode ne $File->{Mode}) ) {
     &add_warning('W07', {
       W07_mime => $File->{ContentType},
       W07_ct   => $File->{Mode},
@@ -1746,12 +1763,17 @@
     return;
   }
 
-  # $File->{Mode} eq 'TBD'
   if ($mode eq 'SGML' or $mode eq 'XML') {
     $File->{Mode} = $mode
   } else {
+    # if by now we still don't know, use SGML as default.
+    # but warn that we are not pleased
+    
     $File->{Mode} = 'SGML';
-    &add_warning('W06', {});
+    &add_warning('W06', {
+      W06_mime => $File->{ContentType},
+      w06_doctype => $File->{Version}
+    });
   }
 }
 

Received on Friday, 16 March 2007 06:56:31 UTC