Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MimeParser improvement for malformed MHT files #489

Closed
clovisribeiro opened this issue Jun 13, 2019 · 2 comments
Closed

MimeParser improvement for malformed MHT files #489

clovisribeiro opened this issue Jun 13, 2019 · 2 comments
Labels
compatibility Compatibility with existing software

Comments

@clovisribeiro
Copy link

I have a MHTML document (with one simple image and a text) that opens in Chrome and Edge, but MimeKit parser returns an Empty HtmlBody when parsing it.

I initially thought this could be a bug in MimeKit and decided to investigate the source code and RFC2387. After further research, it looks to me that MimeKit is strictly following the standards, but Chrome and Edge are a little more “flexible” and parse a document that is incorrectly formatted.

The whole problem is the document is a “Content-Type: multipart/related” and type=”text/html”, so according to what I understood from the standards, either the first part of the document (Root) should be the HTML or a start parameter should point to the part with the appropriate “Content-ID”.

The document that I got (it was generated by DevExpress Inc. RichText control) adds the image in the first part, the HTML in the second part and uses no “start” to point to the Root. The result is MimeKit does not parse it correctly, so no HtmlBody is generated.

My suggestion would be:
(1) Generate an exception when parsing an incorrectly formatted document
or
(2) Be a little more flexible on the standard like Chrome and Edge and opening any way.
If it is multipart/related and text/html, I guess Chrome/Edge simply look up for the HTML part and open it correctly

incorrect_mhtml_file.txt

@jstedfast
Copy link
Owner

That should solve the issue. Thanks.

@jstedfast jstedfast added the compatibility Compatibility with existing software label Jun 14, 2019
@clovisribeiro
Copy link
Author

Thanks for the quick reply and exceptional work on MimeKit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Compatibility with existing software
Projects
None yet
Development

No branches or pull requests

2 participants