- From: Olivier Thereaux via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 07 Sep 2007 07:32:56 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/validator/httpd/cgi-bin
In directory hutz:/tmp/cvs-serv29771/httpd/cgi-bin
Modified Files:
check
Log Message:
applying karl's idea that the doctype declaration
we sneak in should not be at the beginning of the doc,
but rather, just before the root element.
This should fix http://www.w3.org/Bugs/Public/show_bug.cgi?id=857
Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.561
retrieving revision 1.562
diff -u -d -r1.561 -r1.562
--- check 5 Sep 2007 08:20:23 -0000 1.561
+++ check 7 Sep 2007 07:32:54 -0000 1.562
@@ -1538,6 +1538,7 @@
local $org_dtd = '';
local $HTML = '';
local $seen = FALSE;
+ local $seen_root = FALSE;
my $declaration = sub {
$seen = TRUE;
@@ -1551,9 +1552,28 @@
$org_dtd = &ent($_[0]);
}
};
+
+ my $start_element = sub{
+ if ($seen_root) {
+ $HTML .= $_[0]; # Stash it as is... moving on
+ }
+ else {
+ $seen_root = TRUE;
+ if ($seen) {
+ # doctype addition aldready done, we move on
+ $HTML .= $_[0];
+ }
+ else {
+ # no original doctype present, hence none replaced already
+ # => we sneak the chosen doctype before the root elt
+ $HTML .= "$dtd\n" . $_[0];
+ }
+ }
+ };
HTML::Parser->new(default_h => [sub {$HTML .= shift}, 'text'],
- declaration_h => [$declaration, 'text']
+ declaration_h => [$declaration, 'text'],
+ start_h => [$start_element, "text"]
)->parse(join "\n", @{$File->{Content}})->eof();
$File->{Content} = [split /\n/, $HTML];
@@ -1567,7 +1587,6 @@
$File->{Tentative} |= T_ERROR; # Tag it as Invalid.
}
} else {
- unshift @{$File->{Content}}, $dtd;
if ($File->{Opt}->{FB}->{DOCTYPE}) {
&add_warning('W16', {W16_dtd => $File->{Opt}->{DOCTYPE}});
Received on Friday, 7 September 2007 07:33:01 UTC