- From: Ville Skytta via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 06 Jan 2009 21:33:13 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/validator/httpd/cgi-bin In directory hutz:/tmp/cvs-serv20781 Modified Files: check Log Message: Override only the first seen doctype declaration, don't touch any non-doctype declarations. Index: check =================================================================== RCS file: /sources/public/validator/httpd/cgi-bin/check,v retrieving revision 1.632 retrieving revision 1.633 diff -u -d -r1.632 -r1.633 --- check 6 Jan 2009 21:21:08 -0000 1.632 +++ check 6 Jan 2009 21:33:10 -0000 1.633 @@ -1768,17 +1768,23 @@ local $seen_root = FALSE; my $declaration = sub { + my ($tag, $text) = @_; + if ($seen_doctype || uc($tag) ne '!DOCTYPE') { + $HTML .= $text; + return; + } + $seen_doctype = TRUE; - $org_dtd = &ent($_[0]); - ($File->{Root}, $File->{DOCTYPE}) = $_[0] =~ m(<!DOCTYPE\s+(\w[\w\.-]+)\s+(?:PUBLIC|SYSTEM)\s+(?:[\'\"])([^\"\']+)(?:[\"\']).*>)si; + $org_dtd = &ent($text); + ($File->{Root}, $File->{DOCTYPE}) = $text =~ m(<!DOCTYPE\s+(\w[\w\.-]+)\s+(?:PUBLIC|SYSTEM)\s+(?:[\'\"])([^\"\']+)(?:[\"\']).*>)si; # No Override if Fallback was requested, or if override is the same as detected my $known = $CFG->{Types}->{$File->{DOCTYPE}}; if ($File->{Opt}->{FB}->{DOCTYPE} or ($known && $File->{Opt}->{DOCTYPE} eq $known->{Display})) { - $HTML .= $_[0]; # Stash it as is... + $HTML .= $text; # Stash it as is... } else { - $HTML .= "$dtd<!-- $_[0] -->"; + $HTML .= "$dtd<!-- $text -->"; } }; @@ -1801,8 +1807,8 @@ }; HTML::Parser->new(default_h => [sub {$HTML .= shift}, 'text'], - declaration_h => [$declaration, 'text'], - start_h => [$start_element, "text"] + declaration_h => [$declaration, 'tag,text'], + start_h => [$start_element, 'text'] )->parse(join "\n", @{$File->{Content}})->eof(); $File->{Content} = [split /\n/, $HTML];
Received on Tuesday, 6 January 2009 21:33:23 UTC