validator/httpd/cgi-bin check,1.594,1.595

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

Modified Files:
	check 
Log Message:
* making sure that automatic doctype detection does not overwite
  the choice of HTML5 override
* preparing routine for the detection of HTML5 via <!DOCTYPE HTML>



Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.594
retrieving revision 1.595
diff -u -d -r1.594 -r1.595
--- check	15 Aug 2008 18:25:50 -0000	1.594
+++ check	15 Aug 2008 18:52:49 -0000	1.595
@@ -666,22 +666,21 @@
 #
 # Override DOCTYPE if user asked for it.
 if ($File->{Opt}->{DOCTYPE}) {
-    if ($File->{Opt}->{DOCTYPE} eq "HTML5") {
-      $File->{DOCTYPE} = "HTML5";
-      $File->{Version} = $File->{DOCTYPE};        
-    }
-    elsif (not $File->{Opt}->{DOCTYPE} =~ /(Inline|detect)/i) {
-     $File = &override_doctype($File);
-    }
+  if (not $File->{Opt}->{DOCTYPE} =~ /(Inline|detect)/i) {
+   $File = &override_doctype($File);
+  }
 }
 
-if ($File->{Opt}->{DOCTYPE} eq "HTML5") {
-  
-}
-else {
-  # Try to extract a DOCTYPE or xmlns.
-  $File = &preparse_doctype($File);
+# Try to extract a DOCTYPE or xmlns.
+$File = &preparse_doctype($File);
+
+if ($File->{Opt}->{DOCTYPE}) {
+  if ($File->{Opt}->{DOCTYPE} eq "HTML5") {
+    $File->{DOCTYPE} = "HTML5";
+    $File->{Version} = $File->{DOCTYPE};        
+  }
 }
+
 set_parse_mode($File, $CFG);
 #
 # Sanity check Charset information and add any warnings necessary.
@@ -701,8 +700,8 @@
 if (&is_xml($File)) {
   if ($File->{DOCTYPE} eq "HTML5")
   {
-    $File->{DOCTYPE} = "XHTML5";
-    $File->{Version} = "XHTML5";
+    # $File->{DOCTYPE} = "XHTML5";
+    # $File->{Version} = "XHTML5";
   }
   else {
     my $xmlparser = XML::LibXML->new();
@@ -2081,9 +2080,15 @@
     my $declaration = shift;
     my $doctype_type;
     my $doctype_secondpart;
-    ($File->{Root}, $doctype_type, $File->{DOCTYPE}, $doctype_secondpart) = $declaration =~ m(<!DOCTYPE\s+(\w[\w\.-]+)\s+(PUBLIC|SYSTEM)\s+(?:[\'\"])([^\"\']+)(?:[\"\'])(.*)>)si;
-    if (($doctype_type eq "PUBLIC") and (($doctype_secondpart) = $doctype_secondpart =~ m(\s+(?:[\'\"])([^\"\']+)(?:[\"\']).*)si)){
-        &match_DTD_FPI_SI($File, $File->{DOCTYPE}, $doctype_secondpart);
+    if ($declaration =~ m(<!DOCTYPE\s+HTML\s*>)si) {
+      $File->{Root} = "html";
+      $File->{DOCTYPE} = "HTML5";
+    }
+    else {
+      ($File->{Root}, $doctype_type, $File->{DOCTYPE}, $doctype_secondpart) = $declaration =~ m(<!DOCTYPE\s+(\w[\w\.-]+)\s+(PUBLIC|SYSTEM)\s+(?:[\'\"])([^\"\']+)(?:[\"\'])(.*)>)si;
+      if (($doctype_type eq "PUBLIC") and (($doctype_secondpart) = $doctype_secondpart =~ m(\s+(?:[\'\"])([^\"\']+)(?:[\"\']).*)si)){
+          &match_DTD_FPI_SI($File, $File->{DOCTYPE}, $doctype_secondpart);
+      }
     }
   };
 

Received on Friday, 15 August 2008 18:53:25 UTC