<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>29315</bug_id>
          
          <creation_ts>2015-11-30 10:51:38 +0000</creation_ts>
          <short_desc>API validation with HTML5 and JSON output includes headers in content</short_desc>
          <delta_ts>2015-11-30 10:51:38 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML Checker</product>
          <component>General</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="R">bugmezilla</reporter>
          <assigned_to name="Michael[tm] Smith">mike+validator</assigned_to>
          
          
          <qa_contact name="qa-dev tracking">www-validator-cvs</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>124317</commentid>
    <comment_count>0</comment_count>
    <who name="R">bugmezilla</who>
    <bug_when>2015-11-30 10:51:38 +0000</bug_when>
    <thetext>Hi everyone,

It seems that the JSON output is leaking headers into the main content.

Headers such as:

  X-W3C-Validator-Recursion

are printed as part of the response causing programs to fail and complain about invalid JSON.


Tested using the following content as test.html:

  &lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;title&gt;title&lt;/title&gt;
    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
  &lt;/head&gt;
  &lt;body&gt;
    
  &lt;/body&gt;
  &lt;/html&gt;


And the following curl command:

  curl -sF &quot;uploaded_file=@test.html;type=text/html&quot; -F output=json http://validator.w3.org/check


The output I get is:

  Status: 302 Found
  Location: https://validator.w3.org/nu/?doc=test.html&amp;out=json

  Content-Type: application/json; charset=UTF-8
  X-W3C-Validator-Recursion: 1
  X-W3C-Validator-Status: Valid
  X-W3C-Validator-Errors: 0
  X-W3C-Validator-Warnings: 1

  {
      &quot;url&quot;: &quot;test.html&quot;,
      &quot;messages&quot;: [
        
            {
              
              
                &quot;message&quot;: &quot;The Content-Type was text/html. Using the HTML parser.&quot;,
                &quot;messageid&quot;: &quot;html5&quot;,
                &quot;explanation&quot;: &quot;    &lt;p class=\&quot;helpwanted\&quot;&gt;\n      &lt;a\n        href=\&quot;feedback.html?uri=;errmsg_id=html5#errormsg\&quot;\n\ttitle=\&quot;Suggest improvements on this error message through our feedback channels\&quot; \n      &gt;&amp;#x2709;&lt;/a&gt;\n    &lt;/p&gt;\n&quot;,
                &quot;type&quot;: &quot;info&quot;
            },
        
            {
              
              
                &quot;message&quot;: &quot;Using the schema for HTML with SVG 1.1, MathML 3.0, RDFa 1.1, and ITS 2.0 support.&quot;,
                &quot;messageid&quot;: &quot;html5&quot;,
                &quot;explanation&quot;: &quot;    &lt;p class=\&quot;helpwanted\&quot;&gt;\n      &lt;a\n        href=\&quot;feedback.html?uri=;errmsg_id=html5#errormsg\&quot;\n\ttitle=\&quot;Suggest improvements on this error message through our feedback channels\&quot; \n      &gt;&amp;#x2709;&lt;/a&gt;\n    &lt;/p&gt;\n&quot;,
                &quot;type&quot;: &quot;info&quot;
            }
        
          ],
      &quot;source&quot;: {
          &quot;encoding&quot;: &quot;utf-8&quot;,
          &quot;type&quot;: &quot;text/html&quot;
      }
  }</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>