<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - MHTML: Document not displayed due to incorrect folding whitespace handling"
   href="https://bugs.webkit.org/show_bug.cgi?id=158423">158423</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>MHTML: Document not displayed due to incorrect folding whitespace handling
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>WebKit Nightly Build
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Page Loading
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>horst.reiterer&#64;fabasoft.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>beidson&#64;apple.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=280599" name="attach_280599" title="Test Document">attachment 280599</a> <a href="attachment.cgi?id=280599&amp;action=edit" title="Test Document">[details]</a></span>
Test Document

Loading the attached MHTML document (test.mht) in WebKit results in an empty document. The underlying problem is that the MHTML parser does not parse folding whitespace correctly.

The initial header is as follows:

MIME-Version: 1.0
Content-Type: multipart/related;
 boundary=&quot;----=_NextPart_000_0000_01C12184.8FEC43F0&quot;; type=text/html

The second line of the folded Content-Type header starts with a space rather than a tabulator. In RFC2822, folding whitespace is defined as follows:

FWS             =       ([*WSP CRLF] 1*WSP) /   ; Folding white space
                        obs-FWS

So, the second line may start with a space or a tabulator - the input is correct. However, the parser only handles the tabulator case:

qt/qtwebkit/Source/WebCore/platform/network/MIMEHeader.cpp:
        if (line[0] == '\t') {
             ASSERT(!key.isEmpty());

With the attached patch (qt-everywhere-opensource-5.4.1-html-fws-sp.patch) against the WebKit version that comes with QT 5.4.1, the document is displayed as expected.

As the issue occured in the context of QT, we also reported the issue there:

<a href="https://bugreports.qt.io/browse/QTBUG-53869">https://bugreports.qt.io/browse/QTBUG-53869</a></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>