markup-validator commit: Override inline charset indication of HTML5 direct input.

changeset:   3274:096bd336331d
tag:         tip
user:        Ville Skyttä <ville.skytta@iki.fi>
date:        Mon Dec 12 21:50:25 2011 +0200
files:       httpd/cgi-bin/check
description:
Override inline charset indication of HTML5 direct input.

The inline charset indication is supposed to be ignored in direct
input mode, but validator.nu does not work that way but throws an
error if it finds an inconsistency (which may originate from us
always POSTing the file to it as UTF-8).


diff -r aaa4f829403b -r 096bd336331d httpd/cgi-bin/check
--- a/httpd/cgi-bin/check	Mon Dec 12 21:36:36 2011 +0200
+++ b/httpd/cgi-bin/check	Mon Dec 12 21:50:25 2011 +0200
@@ -1048,10 +1048,13 @@
     my $req = HTTP::Request->new(POST => $url);
     my $ct = &is_xml($File) ? "application/xhtml+xml" : "text/html";
 
-    if ($File->{Opt}->{DOCTYPE} || $File->{Charset}->{Override}) {
+    if ($File->{Opt}->{DOCTYPE} || $File->{Charset}->{Override} ||
+        $File->{'Direct Input'})
+    {
 
         # Doctype or charset overridden, need to use $File->{Content} in UTF-8
-        # because $File->{Bytes} is not affected by the overrides.
+        # because $File->{Bytes} is not affected by the  overrides.  Note that
+        # direct input is always considered an override here.
 
         &override_charset($File, "UTF-8");
 
@@ -1068,15 +1071,10 @@
         # is the same later when displaying error contexts (regardless of EOL
         # chars used in the document).
 
-        if ($File->{'Direct Input'}) {
-            $ct .= "; charset=UTF-8";
-        }
-        else {
-            my @ct = ($File->{ContentType} => undef);
-            push(@ct, charset => $File->{Charset}->{HTTP})
-                if $File->{Charset}->{HTTP};
-            $ct = HTTP::Headers::Util::join_header_words(@ct);
-        }
+        my @ct = ($File->{ContentType} => undef);
+        push(@ct, charset => $File->{Charset}->{HTTP})
+            if $File->{Charset}->{HTTP};
+        $ct = HTTP::Headers::Util::join_header_words(@ct);
 
         $req->content_ref(\$File->{Bytes});
     }

Received on Monday, 12 December 2011 19:52:35 UTC