- From: Terje Bless <link@hutz.w3.org>
- Date: Sun, 16 May 2004 02:29:49 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/validator/httpd/cgi-bin In directory hutz:/tmp/cvs-serv22380 Modified Files: Tag: validator-0_6_0-branch check Log Message: Fix Fallback options for Charset and DOCTYPE. This closes Bug #719. Index: check =================================================================== RCS file: /sources/public/validator/httpd/cgi-bin/check,v retrieving revision 1.305.2.117 retrieving revision 1.305.2.118 diff -u -d -r1.305.2.117 -r1.305.2.118 --- check 15 May 2004 16:21:04 -0000 1.305.2.117 +++ check 16 May 2004 02:29:46 -0000 1.305.2.118 @@ -413,29 +413,37 @@ $File->{Charset}->{Use} = $File->{Charset}->{META}; } +# +# Handle any Fallback or Override for the charset. if (&conflict($File->{Opt}->{Charset}, '(detect automatically)')) { + # charset=foo was given to the CGI and it wasn't "autodetect". + + # + # Extract the user-requested charset from CGI param. my ($override, undef) = split(/\s/, $File->{Opt}->{Charset}, 2); $File->{Charset}->{Override} = lc($override); - unless ($File->{Charset}->{Use} and $File->{Opt}->{FB}->{Charset}) { - if ($File->{Opt}->{FB}->{Charset} and not $File->{Charset}->{Use}) { + + if ($File->{Opt}->{FB}->{Charset} and not ) { + unless ($File->{Charset}->{Use}) { &add_warning($File, 'fallback', 'No Character Encoding Found!', <<".EOF."); # Warn about fallback... Falling back to "$File->{Charset}->{Override}" (<a href="docs/users.html#fbc">explain...</a>). .EOF. $File->{Tentative} |= T_ERROR; # Tag it as Invalid. - } else { - # Warn about Override... - unless ($File->{Charset}->{Override} eq $File->{Charset}->{Use}) { - my $cs_use = &ent($File->{Charset}->{Use}); - my $cs_opt = &ent($File->{Charset}->{Override}); - &add_warning($File, 'override', 'Character Encoding Override in effect!', <<".EOF."); + $File->{Charset}->{Use} = $File->{Charset}->{Override}; + } + } else { + # Warn about Override unless it's the same as the real charset... + unless ($File->{Charset}->{Override} eq $File->{Charset}->{Use}) { + my $cs_use = &ent($File->{Charset}->{Use}); + my $cs_opt = &ent($File->{Charset}->{Override}); + &add_warning($File, 'override', 'Character Encoding Override in effect!', <<".EOF."); The detected character encoding "<code>$cs_use</code>" has been suppressed and "<code>$cs_opt</code>" used instead. .EOF. - $File->{Tentative} |= T_ERROR; - } + $File->{Tentative} |= T_ERROR; + $File->{Charset}->{Use} = $File->{Charset}->{Override}; } - $File->{Charset}->{Use} = $File->{Charset}->{Override}; } } @@ -1636,8 +1644,11 @@ my $declaration = sub { $seen = TRUE; + # No Override if Fallback was requested. - unless ($File->{Opt}->{FB}->{DOCTYPE}) { + if ($File->{Opt}->{FB}->{DOCTYPE}) { + $HTML .= $_[0]; # Stash it as is... + } else { # Comment it out and insert the new one... $HTML .= "$dtd\n" . '<!-- ' . $_[0] . ' -->'; $org_dtd = &ent($_[0]); } @@ -2605,18 +2616,6 @@ my $cs_meta = $File->{Charset}->{META} ? &ent($File->{Charset}->{META}) : ''; # - # warn about charset override - if ($File->{Charset}->{Override} && - $File->{Charset}->{Override} ne $File->{Charset}->{Use}) { - &add_warning($File, 'override', 'Character Encoding Override in effect!', <<".EOF."); - The detected character encoding, "<code>$cs_use</code>", has been - suppressed and the character encoding "<code>$cs_opt</code>" used - instead. -.EOF. - $File->{Tentative} |= T_ERROR; - } - - # # Add a warning if there was charset info conflict (HTTP header, # XML declaration, or <meta> element). if (&conflict($File->{Charset}->{HTTP}, $File->{Charset}->{XML})) {
Received on Saturday, 15 May 2004 22:31:26 UTC