summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorot <ot@localhost>2005-03-24 08:37:27 +0000
committerot <ot@localhost>2005-03-24 08:37:27 +0000
commite42e8d96e86407b7e8dfb377d5f438fe479c8d28 (patch)
tree49e1575c8156d10983de2390814bc9a25656f19b
parent1fba49e07250993efbb43361c839d8f1d7d93a1a (diff)
downloadmarkup-validator-e42e8d96e86407b7e8dfb377d5f438fe479c8d28.zip
markup-validator-e42e8d96e86407b7e8dfb377d5f438fe479c8d28.tar.gz
markup-validator-e42e8d96e86407b7e8dfb377d5f438fe479c8d28.tar.bz2
Modifying warnings when a charset override has been selected for a document with no charset declared at all.
Should fix http://www.w3.org/Bugs/Public/show_bug.cgi?id=1133
-rwxr-xr-xhttpd/cgi-bin/check35
-rw-r--r--share/templates/en_US/warnings.tmpl20
2 files changed, 41 insertions, 14 deletions
diff --git a/httpd/cgi-bin/check b/httpd/cgi-bin/check
index d04d5d4..859a7ea 100755
--- a/httpd/cgi-bin/check
+++ b/httpd/cgi-bin/check
@@ -9,7 +9,7 @@
# This source code is available under the license at:
# http://www.w3.org/Consortium/Legal/copyright-software
#
-# $Id: check,v 1.407 2005-03-24 02:41:12 ot Exp $
+# $Id: check,v 1.408 2005-03-24 08:37:26 ot Exp $
#
# Disable buffering on STDOUT!
@@ -220,7 +220,7 @@ Directory not readable (permission denied): @_r
#
# Strings
- $VERSION = q$Revision: 1.407 $;
+ $VERSION = q$Revision: 1.408 $;
$VERSION =~ s/Revision: ([\d\.]+) /$1/;
#
@@ -454,29 +454,40 @@ if (&conflict($File->{Opt}->{Charset}, '(detect automatically)')) {
my ($override, undef) = split(/\s/, $File->{Opt}->{Charset}, 2);
$File->{Charset}->{Override} = lc($override);
- if ($File->{Opt}->{FB}->{Charset}) {
+ if ($File->{Opt}->{FB}->{Charset}) { # charset fallback mode
unless ($File->{Charset}->{Use}) {
&add_warning('W02', {W02_charset => $File->{Charset}->{Override}});
$File->{Tentative} |= T_ERROR; # Tag it as Invalid.
$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}) {
- &add_warning('W03', {
- W03_use => $File->{Charset}->{Use},
- W03_opt => $File->{Charset}->{Override},
- });
-
+ } else { # charset "hard override" mode
+ if (! $File->{Charset}->{Use}) { # overriding "nothing"
+ &add_warning('W04', {W04_charset => $File->{Charset}->{Override}, W04_override => TRUE});
$File->{Tentative} |= T_ERROR;
$File->{Charset}->{Use} = $File->{Charset}->{Override};
+ }
+ else { #actually overriding something
+ # Warn about Override unless it's the same as the real charset...
+
+ unless ($File->{Charset}->{Override} eq $File->{Charset}->{Use}) {
+ &add_warning('W03', {
+ W03_use => $File->{Charset}->{Use},
+ W03_opt => $File->{Charset}->{Override},
+ });
+
+ $File->{Tentative} |= T_ERROR;
+ $File->{Charset}->{Use} = $File->{Charset}->{Override};
+ }
}
+
+
+
}
}
unless ($File->{Charset}->{Use}) { # No charset given...
- &add_warning('W04', {});
+ &add_warning('W04', {W04_charset => 'UTF-8'});
$File->{Tentative} |= T_ERROR; # Can never be valid.
$File->{Charset}->{Use} = 'utf-8';
}
diff --git a/share/templates/en_US/warnings.tmpl b/share/templates/en_US/warnings.tmpl
index 319709d..110af10 100644
--- a/share/templates/en_US/warnings.tmpl
+++ b/share/templates/en_US/warnings.tmpl
@@ -48,15 +48,31 @@
</TMPL_IF>
<TMPL_IF NAME="W04">
<dt id="W04">No Character Encoding Found!
- Falling back to <code>UTF-8</code>.</dt>
+ <TMPL_IF NAME="W04_override">
+ Using
+ <TMPL_ELSE>
+ Falling back to
+ </TMPL_IF>
+ <code><TMPL_IF NAME="W04_charset"><TMPL_VAR NAME="W04_charset" ESCAPE="HTML"><TMPL_ELSE>UTF-8</TMPL_IF></code>.
+ </dt>
<dd>
+ <TMPL_IF NAME="W04_override">
+ <p>I was not able to extract a character encoding labeling from any of
+ the valid sources for such information. I will use the character
+ encoding <code><TMPL_IF NAME="W04_charset"><TMPL_VAR NAME="W04_charset" ESCAPE="HTML"><TMPL_ELSE>UTF-8</TMPL_IF></code>,
+ which you have chosen via the <code>Encoding</code> override option, for
+ tentative validation.
+ </p>
+ <TMPL_ELSE>
<p>
I was not able to extract a character encoding labeling from any of
the valid sources for such information. Without encoding information
it is impossible to reliably validate the document. I'm falling back
- to the "UTF-8" encoding and will attempt to perform the validation,
+ to the "<code><TMPL_IF NAME="W04_charset"><TMPL_VAR NAME="W04_charset" ESCAPE="HTML"><TMPL_ELSE>UTF-8</TMPL_IF></code>"
+ encoding and will attempt to perform the validation,
but this is likely to fail for all non-trivial documents.
</p>
+ </TMPL_IF>
<TMPL_IF NAME="opt_verbose">
<p>The sources I tried to find encoding information include:</p>
<ul>