diff options
author | ot <ot@localhost> | 2007-03-07 08:07:12 +0000 |
---|---|---|
committer | ot <ot@localhost> | 2007-03-07 08:07:12 +0000 |
commit | c7ba81e5c508cc958ce82b88e8d68d2b3db9970f (patch) | |
tree | f4c49462635f96dd44c96ce448e4bc640f6359e6 | |
parent | 24d896c984ea9aa6e8a83e2b67265aeff9ed37de (diff) | |
download | markup-validator-c7ba81e5c508cc958ce82b88e8d68d2b3db9970f.zip markup-validator-c7ba81e5c508cc958ce82b88e8d68d2b3db9970f.tar.gz markup-validator-c7ba81e5c508cc958ce82b88e8d68d2b3db9970f.tar.bz2 |
Adding a check for a mime type / doctype conflict.
Warning wording in progress, including suggestions by Philip "nikitathespider"
and Frank Ellermann.
-rwxr-xr-x | httpd/cgi-bin/check | 19 | ||||
-rw-r--r-- | share/templates/en_US/warnings.tmpl | 22 |
2 files changed, 39 insertions, 2 deletions
diff --git a/httpd/cgi-bin/check b/httpd/cgi-bin/check index 8ef4627..a862fdb 100755 --- a/httpd/cgi-bin/check +++ b/httpd/cgi-bin/check @@ -14,7 +14,7 @@ # This source code is available under the license at: # http://www.w3.org/Consortium/Legal/copyright-software # -# $Id: check,v 1.472 2007-03-02 07:08:16 ot Exp $ +# $Id: check,v 1.473 2007-03-07 08:07:11 ot Exp $ # # Disable buffering on STDOUT! @@ -180,7 +180,7 @@ Directory not readable (permission denied): @_r # # Strings - $VERSION = q$Revision: 1.472 $; + $VERSION = q$Revision: 1.473 $; $VERSION =~ s/Revision: ([\d\.]+) /$1/; # @@ -668,6 +668,21 @@ if (my $prettyver = $CFG->{Types}->{$File->{Version}}->{Display}) { } # +# check the received mime type against Allowed mime types +if ($File->{ContentType}){ + my @allowedMediaType = split(" ", $CFG->{Types}->{$File->{DOCTYPE}}->{Types}->{Allowed}); + my $usedCTisAllowed = FALSE; + foreach (@allowedMediaType) { $usedCTisAllowed = TRUE if ($_ eq $File->{ContentType}); } + if(! $usedCTisAllowed ){ + &add_warning('W23', { + W23_type => $File->{ContentType}, + W23_type_pref => $CFG->{Types}->{$File->{DOCTYPE}}->{Types}->{Preferred}, + w23_doctype => $File->{Version} + }); + } +} + +# # Warn about unknown, incorrect, or missing Namespaces. if ($File->{Namespace}) { my $ns = $CFG->{Types}->{$File->{Version}}->{Namespace} || FALSE; diff --git a/share/templates/en_US/warnings.tmpl b/share/templates/en_US/warnings.tmpl index e2a46da..0b1952d 100644 --- a/share/templates/en_US/warnings.tmpl +++ b/share/templates/en_US/warnings.tmpl @@ -370,6 +370,28 @@ </li> </TMPL_IF> +<TMPL_IF NAME="W23"> + <li class="msg_warn" id="W23"><span class="msg">Conflict between Mime Type and Document Type</span> + + <p>The document is being served with the <code><TMPL_VAR NAME="W23_type" ESCAPE="HTML"></code> Mime Type + which is not a registered media type for the + <code><TMPL_VAR NAME="W23_doctype" ESCAPE="HTML"></code> Document Type. The recommended media type + for this document is: <code><TMPL_VAR NAME="W23_type_pref" ESCAPE="HTML"></code></p> + + <p>Using a wrong media type for a certain document type may + confuse the validator and other user agents with respect to the + nature of the document, and you may get some erroneous validation + errors. How to fix this problem? One of the following techniques should help:</p> + <ul> + <li>If you are serving a static file on a Web server, changing its extension should help. + Use e.g <code>.xhtml</code> for XHTML or <code>.mathml</code> for MathML. + </li> + <li>You may need to reconfigure your Web server. This <a href="http://www.developershome.com/wap/wapServerSetup/tutorial.asp?page=settingUpMIME">Setting up MIME Types tutorial</a> has instructions for Apache, Tomcat and IIS. +</li> + <li>If the document is generated dynamically, the scripting language should allow you to set up the mime type: + this <a href="http://juicystudio.com/article/content-negotiation.php">article on MIME Types and Content Negotiation</a> has examples in PHP, Perl, and ASP.</li> +</TMPL_IF> + <TMPL_IF NAME="W@@"> <li class="msg_warn" id="W@@"> |