Re: Possible patch for explicit doctype error message

Hi Chuck,

On Wed, Oct 24, 2007, Chuck Houpt wrote:
> When validating a page with a user selected Doctype (eg 
> doctype=XHTML+1.0+Strict), the validator produces an error message 
> (either to Apache's error log or standard error):
> 
> The following patch suppresses the error, but maybe there is a better 
> way to fix this? The issue is that when override_doctype() is first 
> called (line 628), $File->{DOCTYPE} hasn't been set yet. Possibly 
> $File->{DOCTYPE} should be initialized to '' earlier in the script? 

I think your patch will work for most cases, unless the existing doctyle
being overriden is not known in the types config. So maybe something
like this?

===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.577
diff -u -r1.577 check
--- check       25 Oct 2007 19:43:57 -0000      1.577
+++ check       1 Nov 2007 19:22:45 -0000
@@ -1636,7 +1636,11 @@
   $File->{Content} = [split /\n/, $HTML];
 
   if ($seen) {
-    unless (($File->{Opt}->{FB}->{DOCTYPE}) or ($File->{Opt}->{DOCTYPE} eq $CFG->{Types}->{$File->{DOCTYPE}}->{Display} )) {
+    my $old_doctype_name;
+    if (defined $File->{DOCTYPE}) {
+      if (defined $CFG->{Types}->{$File->{DOCTYPE}}->{Display}) {$old_doctype_name = $CFG->{Types}->{$File->{DOCTYPE}}->{Display}}
+    } 
+    unless (($File->{Opt}->{FB}->{DOCTYPE}) or ($File->{Opt}->{DOCTYPE} eq $old_doctype_name)) {
       &add_warning('W13', {
         W13_org => $org_dtd,
         W13_new => $File->{Opt}->{DOCTYPE},

-- 
olivier

Received on Thursday, 1 November 2007 19:36:57 UTC