{"id":21,"date":"2004-09-07T10:33:30","date_gmt":"2004-09-07T10:33:30","guid":{"rendered":"http:\/\/lachy.id.au\/log\/2004\/09\/validating-xhtml-with-ie-using-file-upload"},"modified":"2008-04-30T22:39:29","modified_gmt":"2008-04-30T22:39:29","slug":"validating-xhtml-with-ie-using-file","status":"publish","type":"post","link":"https:\/\/lachy.id.au\/log\/2004\/09\/validating-xhtml-with-ie-using-file","title":{"rendered":"Validating (X)HTML With IE Using File Upload"},"content":{"rendered":"<ins datetime=\"2004-09-08T07:05:00+10:00\" class=\"warning\">\r\n<p><strong>Warning:<\/strong> The following describes how to modify\r\n\tthe registry in order to <em>trick<\/em> Windows XP <abbr title=\"Service Pack 2\">SP2<\/abbr> into\r\n\tallowing <code>text\/html<\/code> to be sent with file uploads.  This hack has\r\n\tknown side affects which may affect other applications running on your system,\r\n\tsome of which are discussed in the comments. As a result, I accept no responsibility\r\n\tfor damage caused to your system as a result of applying this hack, and this\r\n\tsolution is provided as-is, with no guarentee, warranty or support.  If you do not understand the regitry, nor how to reverse any change, then <strong>do\r\n\t\tnot<\/strong> apply these changes \u2013 <em>use them at your own risk<\/em>.<\/p>\r\n<\/ins>\r\n\r\n<ins datetime=\"2006-11-23T05:52Z\"><p><strong>Update:<\/strong> This technique is no longer required for HTML.  Please see <a href=\"http:\/\/www.w3.org\/QA\/2005\/01\/Validator-IE_WinXP_SP2\">Validation by file upload and Internet Explorer on WinXP SP2<\/a><\/p><\/ins>\r\n\r\n<p>After downloading Windows XP Service Pack 2 recently, I was shocked that <abbr title=\"Internet Explorer\">IE<\/abbr> was now sending <abbr title=\"HyperText Markup Language\">HTML<\/abbr> documents with a <code>.htm<\/code> or <code>.html<\/code> extension as <code>text\/plain<\/code>, thus causing any the <a href=\"http:\/\/validator.w3.org\/\"><cite><abbr title=\"World Wide Web Consortium\">W3C<\/abbr> Markup Validator<\/cite><\/a> to issue this warning message:<\/p>\r\n<blockquote>\r\n<p>\r\n        Sorry, I am unable to validate this document because its content type\r\n        is <code>text\/plain<\/code>, which is not currently supported by this service.\r\n      <\/p>\r\n      <p>\r\n        The Content-Type field is sent by your web server (or web browser if\r\n        you use the file upload interface) and depends on its configuration.\r\n        Commonly, web servers will have a mapping of filename extensions\r\n        (such as &#8220;.html&#8221;) to <abbr title=\"Multipurpose Internet Mail Extensions\">MIME<\/abbr>\r\n        <code>Content-Type<\/code> values (such as <code>text\/html<\/code>).\r\n      <\/p>\r\n      <p>\r\n        That you recieved this message can mean that your server is\r\n        not configured correctly, that your file does not have the correct\r\n        filename extension, or that you are attempting to validate a file\r\n        type that we do not support yet. In the latter case you should let\r\n        us know that you need us to support that content type (please include\r\n        all relevant details, including the URL to the standards document\r\n        defining the content type) using the instructions on the\r\n        Feedback Page.\r\n      <\/p>\r\n<\/blockquote>\r\n\r\n<p>This essentially means that it was impossible to validate any local <abbr title=\"HyperText Markup Langauge\">HTML<\/abbr> document using <abbr title=\"Internet Explorer\">IE<\/abbr>.  This is really annoying, especially for any unfortunate developers who are forced to develop using only <abbr title=\"Internet Explorer\">IE<\/abbr> at work.  Although I do pity anyone in that situation, <em>there is now some relief!<\/em><\/p>\r\n\r\n<p>After spending about half an hour searching through the registry for any setting that could be causing <code>.html<\/code> files to be sent as <code>text\/plain<\/code>, I realised that it would be eaiser to find where the setting for other content types that do work, such as <abbr title=\"Cascading Style Sheets\">CSS<\/abbr>.  So, I found the setting for that, modified, and tested.  When the <abbr title=\"Cascading Style Sheets\">CSS<\/abbr> <code>Content Type<\/code> value was set to anything but <code>text\/html<\/code>, <abbr title=\"Internet Explorer\">IE<\/abbr> uploaded the file with that <abbr title=\"Multipurpose Internet Mail Exchange\">MIME<\/abbr> type.  Thus, I came to the conclusion that it was not that the setting was incorrect, but that something in Windows security was preventing any <code>text\/html<\/code> content being sent by changing it to <code>text\/plain<\/code> on the way.<\/p>\r\n\r\n<p>After that, I tried setting the valud for <code>.html<\/code> files to another type that the validator may support, such as <code>text\/sgml<\/code> or <code>application\/sgml<\/code>, but sadly, without luck!  But, just before giving up all hope, I realised that perhaps Windows security, being as insecure as ever, is only checking for an exact match on the content type being set by <abbr title=\"Internet Explorer\">IE<\/abbr> with file uploads.  I was correct!<\/p>\r\n\r\n<p>In a normal <abbr title=\"HyperText Transfer Protocol\">HTTP<\/abbr> header, the <code>Content-Type<\/code> can also include a <code>charset<\/code> parameter.  For example:<\/p>\r\n\r\n<pre><code><span>Content-Type<\/span>: text\/html; charset=UTF-8<\/code><\/pre>\r\n<p>So, I figured, what if I want <abbr title=\"Internet Explorer\">IE<\/abbr> to send a charset parameter also.  I set the <code>Content Type<\/code> value in the registry to that above, and it worked perfectly \u2014 the file validated!!!  However, the charset will not always be <code>UTF-8<\/code>, or any other charset for that matter, so I removed the chaset parameter, and was left with the value <code>text\/html;<\/code>  That extra little semi-colon on the end is enough to bypass Windows security, and validate any <abbr title=\"HyperText Markup Language\">HTML<\/abbr> file.<\/p>\r\n\r\n<p>Then, I remembered that IE also does not know how to validate <abbr title=\"Extensible HyperText Markup Language\">XHTML<\/abbr> documents either.  So, I went to the registry key for <code>.xhtml<\/code> files, added the <code>application\/xhtml+xml<\/code> <abbr title=\"Multipurpose Internet Mail Exchange\">MIME<\/abbr> type, tested and Guess What! <strong>It Worked<\/strong>.<\/p>\r\n\r\n<p>I have exported the required settings from the registry and they are availble here.  <a href=\"\/dev\/2004\/09\/IE6-SP2-Content-Type-text-html.reg\">IE6-SP2-Content-Type-text-html.reg<\/a> will fix the value for <code>text\/html<\/code>, and <a href=\"\/dev\/2004\/09\/IE6-SP2-Content-Type-application-xhtml+xml.reg\">IE6-SP2-Content-Type-application-xhtml+xml.reg<\/a> will add the <abbr title=\"Multipurpose Internet Mail Exchange\">MIME<\/abbr> type for <abbr title=\"Extensible HyperText Markup Language\">XHTML<\/abbr> documents.  Download them both, inspect their contents to ensure that they are safe, and apply them by launching them.  You will be prompted by Windows to confirm that you want to apply the settings.<\/p>\r\n\r\n<ins datetime=\"2004-09-08T00:55:00+10:00\"><p><strong>Update:<\/strong> For any users of <a href=\"http:\/\/www.icq.com\/\">ICQ<\/a>: If you use change the <code>text\/html<\/code> value to <code>text\/html;<\/code> then each time the ICQ advertisement rotates, you may be prompted to save the file, because it is an unknown file type.  I don\u2019t konw why this happens, because <abbr title=\"Internet Explorer\">IE<\/abbr> still works the same as always \u2014 <em>full of bugs!<\/em>  But for some reason it affects ICQ.  I recommend you only apply that work around on computers that you do not use ICQ on, or else change it each time you need to validate with <abbr title=\"Internet Explorer\">IE<\/abbr>.<\/p><\/ins>\r\n","protected":false},"excerpt":{"rendered":"Warning: The following describes how to modify the registry in order to trick Windows XP SP2 into allowing text\/html to be sent with file uploads. This hack has known side affects which may affect other applications running on your system, some of which are discussed in the comments. As a result, I accept no responsibility &hellip; <a href=\"https:\/\/lachy.id.au\/log\/2004\/09\/validating-xhtml-with-ie-using-file\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Validating (X)HTML With IE Using File Upload<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[15,7,6],"tags":[],"_links":{"self":[{"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/posts\/21"}],"collection":[{"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/comments?post=21"}],"version-history":[{"count":0,"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/posts\/21\/revisions"}],"wp:attachment":[{"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/media?parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/categories?post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lachy.id.au\/log\/wp-json\/wp\/v2\/tags?post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}