diff options
author | ot <ot@localhost> | 2008-08-15 18:52:49 +0000 |
---|---|---|
committer | ot <ot@localhost> | 2008-08-15 18:52:49 +0000 |
commit | bce66e19c5b4823d4b74840d8b03bb9a50c3b820 (patch) | |
tree | 7e4ff9edef98f438862b42cf8af0f732bb7a75f7 | |
parent | 64d61fdc00b7d354bec615d1f308e75ca8f1a80d (diff) | |
download | markup-validator-bce66e19c5b4823d4b74840d8b03bb9a50c3b820.zip markup-validator-bce66e19c5b4823d4b74840d8b03bb9a50c3b820.tar.gz markup-validator-bce66e19c5b4823d4b74840d8b03bb9a50c3b820.tar.bz2 |
* making sure that automatic doctype detection does not overwite
the choice of HTML5 override
* preparing routine for the detection of HTML5 via <!DOCTYPE HTML>
-rwxr-xr-x | httpd/cgi-bin/check | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/httpd/cgi-bin/check b/httpd/cgi-bin/check index 2d7c092..98c033f 100755 --- a/httpd/cgi-bin/check +++ b/httpd/cgi-bin/check @@ -14,7 +14,7 @@ # This source code is available under the license at: # http://www.w3.org/Consortium/Legal/copyright-software # -# $Id: check,v 1.594 2008-08-15 18:25:50 ot Exp $ +# $Id: check,v 1.595 2008-08-15 18:52:49 ot Exp $ # # Disable buffering on STDOUT! @@ -191,7 +191,7 @@ Directory not readable (permission denied): @_r # # Strings - $VERSION = q$Revision: 1.594 $; + $VERSION = q$Revision: 1.595 $; $VERSION =~ s/Revision: ([\d\.]+) /$1/; # @@ -666,22 +666,21 @@ if ($File->{Charset}->{Use} eq 'utf-8' && # # 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 @@ $File->{Errors} = []; 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 @@ sub preparse_doctype { 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); + } } }; |