Bug 158423 - MHTML: Document not displayed due to incorrect folding whitespace handling
Summary: MHTML: Document not displayed due to incorrect folding whitespace handling
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-06 09:35 PDT by Horst Reiterer
Modified: 2016-06-06 23:23 PDT (History)
2 users (show)

See Also:


Attachments
Proposed patch (1.34 KB, application/octet-stream)
2016-06-06 09:35 PDT, Horst Reiterer
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Horst Reiterer 2016-06-06 09:35:26 PDT
Created attachment 280599 [details]
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="----=_NextPart_000_0000_01C12184.8FEC43F0"; 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:

https://bugreports.qt.io/browse/QTBUG-53869
Comment 1 Horst Reiterer 2016-06-06 09:35:53 PDT
Created attachment 280600 [details]
Proposed patch
Comment 2 Alexey Proskuryakov 2016-06-06 23:23:39 PDT
Thank you for looking into this, and for the patch!

Unfortunately, webkit.org is not the right place for this patch. MHTML support has been removed from WebKit mainline long ago, so now we don't even have this file any more. This seems to have been made for some old fork.