- From: Olivier Thereaux via cvs-syncmail <cvsmail@w3.org>
- Date: Wed, 03 Oct 2007 10:42:11 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/validator/httpd/cgi-bin
In directory hutz:/tmp/cvs-serv633/httpd/cgi-bin
Modified Files:
check
Log Message:
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).
Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.572
retrieving revision 1.573
diff -u -d -r1.572 -r1.573
--- check 27 Sep 2007 10:13:36 -0000 1.572
+++ check 3 Oct 2007 10:42:08 -0000 1.573
@@ -267,6 +267,9 @@
$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 @@
$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 @@
$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 @@
$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 ($) {
Received on Wednesday, 3 October 2007 10:42:19 UTC