diff options
author | ot <ot@localhost> | 2007-10-03 10:42:09 +0000 |
---|---|---|
committer | ot <ot@localhost> | 2007-10-03 10:42:09 +0000 |
commit | afe0da4953b41826b58b4339f4066be173058121 (patch) | |
tree | 67f29cd76593cd8b5d01303ad0fcbfab0dd791b4 | |
parent | f4b38e28224a6b466f41c09de5448738127c80ae (diff) | |
download | markup-validator-afe0da4953b41826b58b4339f4066be173058121.zip markup-validator-afe0da4953b41826b58b4339f4066be173058121.tar.gz markup-validator-afe0da4953b41826b58b4339f4066be173058121.tar.bz2 |
Fix for http://www.w3.org/Bugs/Public/show_bug.cgi?id=3663
Checking if doctype-less documents display patterns specific to SVG
(svg root element, with or without version/baseProfile attributes)
and, upon detection, applying "fake" doctype override to help validation
of doctype-less SVG 1.0, 1.1 (including Tiny and Basic).
-rwxr-xr-x | httpd/cgi-bin/check | 56 | ||||
-rw-r--r-- | share/templates/en_US/soap_warnings.tmpl | 3 | ||||
-rw-r--r-- | share/templates/en_US/ucn_warnings.tmpl | 4 | ||||
-rw-r--r-- | share/templates/en_US/warnings.tmpl | 9 |
4 files changed, 66 insertions, 6 deletions
diff --git a/httpd/cgi-bin/check b/httpd/cgi-bin/check index 7775820..2a6b7fa 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.572 2007-09-27 10:13:36 ot Exp $ +# $Id: check,v 1.573 2007-10-03 10:42:08 ot Exp $ # # Disable buffering on STDOUT! @@ -186,7 +186,7 @@ Directory not readable (permission denied): @_r # # Strings - $VERSION = q$Revision: 1.572 $; + $VERSION = q$Revision: 1.573 $; $VERSION =~ s/Revision: ([\d\.]+) /$1/; # @@ -267,6 +267,9 @@ $File->{XMLWF_ONLY} = FALSE; $File->{Warnings} = []; # Warnings... $File->{Namespaces} = []; # Other (non-root) Namespaces. +# By default, doctype-less documents can not be valid +$File->{"DOCTYPEless OK"} = FALSE; + ############################################################################### #### Generate Template for Result. ############################################ ############################################################################### @@ -1636,8 +1639,10 @@ sub override_doctype { $File->{Tentative} |= T_ERROR; # Tag it as Invalid. } } else { - - if ($File->{Opt}->{FB}->{DOCTYPE}) { + if ($File->{"DOCTYPEless OK"}) { + &add_warning('W25', {W25_dtd => $File->{Opt}->{DOCTYPE}}); + } + elsif ($File->{Opt}->{FB}->{DOCTYPE}) { &add_warning('W16', {W16_dtd => $File->{Opt}->{DOCTYPE}}); $File->{Tentative} |= T_ERROR; # Tag it as Invalid. } else { @@ -1896,6 +1901,8 @@ sub preparse_doctype { $File->{Root} = $tag; } if ($attr->{xmlns}) {$File->{Namespace} = $attr->{xmlns}}; + if ($attr->{version}) {$File->{'Root Version'} = $attr->{version}}; + if ($attr->{baseProfile}) {$File->{'Root BaseProfile'} = $attr->{baseProfile}}; }; # we use HTML::Parser as pre-parser. May use html5lib or other in the future @@ -1916,9 +1923,50 @@ sub preparse_doctype { $File->{DOCTYPE} =~ s(\s+$){ }g; $File->{DOCTYPE} =~ s(\s+) { }g; + # Some document types actually need no doctype to be identified, + # root element and some version attribute is enough + # TODO applicable doctypes should be migrated to a config file? + + if (($File->{DOCTYPE} eq '') and ($File->{Root} eq "svg") ) { + if (($File->{'Root Version'}) or ($File->{'Root BaseProfile'})) + { + if ($File->{'Root Version'} eq "1.0"){ + $File->{DOCTYPE} = "-//W3C//DTD SVG 1.0//EN"; + $File->{"DOCTYPEless OK"} = TRUE; + $File->{Opt}->{DOCTYPE} = "SVG 1.0"; + } + elsif ((($File->{'Root Version'} eq "1.1") or (!$File->{'Root Version'})) and ($File->{'Root BaseProfile'} eq "tiny")) { + $File->{DOCTYPE} = "-//W3C//DTD SVG Tiny 1.1//EN"; + $File->{"DOCTYPEless OK"} = TRUE; + $File->{Opt}->{DOCTYPE} = "SVG 1.1 Tiny"; + } + elsif ((($File->{'Root Version'} eq "1.1") or (!$File->{'Root Version'})) and ($File->{'Root BaseProfile'} eq "basic")) { + $File->{DOCTYPE} = "-//W3C//DTD SVG Basic 1.1//EN"; + $File->{Opt}->{DOCTYPE} = "SVG 1.1 Basic"; + $File->{"DOCTYPEless OK"} = TRUE; + } + elsif (($File->{'Root Version'} eq "1.1") and (!$File->{'Root BaseProfile'})) { + $File->{DOCTYPE} = "-//W3C//DTD SVG 1.1//EN"; + $File->{Opt}->{DOCTYPE} = "SVG 1.1"; + $File->{"DOCTYPEless OK"} = TRUE; + } + } + else { + # by default for an svg root elt, we use SVG 1.1 + $File->{DOCTYPE} = "-//W3C//DTD SVG 1.1//EN"; + $File->{Opt}->{DOCTYPE} = "SVG 1.1"; + $File->{"DOCTYPEless OK"} = TRUE; + } + } + if (($File->{"DOCTYPEless OK"}) and ($File->{Opt}->{DOCTYPE})) { + # doctypeless document type found, we fake the override + # so that the parser will have something to validate against + $File = &override_doctype($File); + } return $File; } + # # Print out the raw error output for debugging. sub show_errors ($) { diff --git a/share/templates/en_US/soap_warnings.tmpl b/share/templates/en_US/soap_warnings.tmpl index c74a636..289b8eb 100644 --- a/share/templates/en_US/soap_warnings.tmpl +++ b/share/templates/en_US/soap_warnings.tmpl @@ -82,6 +82,9 @@ <TMPL_IF NAME="W24"> <m:warning><m:messageid>W24</m:messageid><m:message>Rare or unregistered Character Encoding detected</m:message></m:warning> </TMPL_IF> +<TMPL_IF NAME="W25"> + <m:warning><m:messageid>W25</m:messageid><m:message><TMPL_VAR NAME="W25_dtd" ESCAPE="HTML"> document without DOCTYPE detected</m:message></m:warning> +</TMPL_IF> <TMPL_IF NAME="W@@"> <m:warning><m:messageid>W@@</m:messageid><m:message></m:message></m:warning> diff --git a/share/templates/en_US/ucn_warnings.tmpl b/share/templates/en_US/ucn_warnings.tmpl index b284729..beaeabe 100644 --- a/share/templates/en_US/ucn_warnings.tmpl +++ b/share/templates/en_US/ucn_warnings.tmpl @@ -82,7 +82,9 @@ <TMPL_IF NAME="W24"> <warning><messageid>W24</messageid><message>Rare or unregistered Character Encoding detected</message></warning> </TMPL_IF> - +<TMPL_IF NAME="W25"> + <warning><messageid>W25</messageid><message><TMPL_VAR NAME="W25_dtd" ESCAPE="HTML"> document without DOCTYPE detected</message></warning> +</TMPL_IF> <TMPL_IF NAME="W@@"> <warning><messageid>W@@</messageid><message></message></warning> </TMPL_IF> diff --git a/share/templates/en_US/warnings.tmpl b/share/templates/en_US/warnings.tmpl index 4ca6f10..2b41a60 100644 --- a/share/templates/en_US/warnings.tmpl +++ b/share/templates/en_US/warnings.tmpl @@ -453,7 +453,14 @@ to check these potential issues, and, if necessary, fix them and re-validate the </li> </TMPL_IF> - +<TMPL_IF NAME="W25"> + <li class="msg_warn" id="W25"><p><span class="err_type"><img src="images/info_icons/warning.png" alt="Warning" title="Warning" /></span> <span class="msg"><TMPL_VAR NAME="W25_dtd" ESCAPE="HTML"> document without DOCTYPE detected.</span></p> + + <p>This document does not declare any DOCTYPE. A Doctype declaration is generally + needed for validation, but the checked document uses markup specific to <TMPL_VAR NAME="W25_dtd" ESCAPE="HTML">, which may be used without DOCTYPE. </p> + <p>Validation was performed as if the DOCTYPE for <TMPL_VAR NAME="W25_dtd" ESCAPE="HTML"> was present. If this automatic detection is not correct, <a href="http://www.w3.org/QA/2002/04/valid-dtd-list.html" title="W3C QA - Recommended list of DTDs you can use in your Web document">adding a DOCTYPE declaration</a> will help validate without ambiguity.</p> + </li> +</TMPL_IF> <TMPL_IF NAME="W@@"> <li class="msg_warn" id="W@@"> |