BUG: PersistStreamInit::Load() Displays HTML Files as Text (323569)
The information in this article applies to:
- Microsoft Internet Explorer (Programming) 6 (SP1)
- Microsoft Internet Explorer (Programming) 5.5 SP2
This article was previously published under Q323569 SYMPTOMS
If you host the WebBrowser control, you may want to load HTML files from memory by using the IPersistStreamInit::Load() interface on MSHTML. Sometimes, however, you may notice that using this method causes the WebBrowser control to display your HTML file as plain text (that is, you see the raw HTML tags, and not rendered content). This is particularly noticeable in HTML pages with large SCRIPT blocks, or large chunks of plain text with no intervening markup.
CAUSE
When it loads an HTML document from Load(), MSHTML must perform MIME-sniffing (that is, it must detect the MIME type by inspecting the leading bytes of the file). However, a bug in MSHTML causes that component to make a second try at MIME detection without resetting its IStream pointer in the memory buffer. If the next chunk of text contains little or no markup, MSHTML recognizes it as text/plain, and overwrites the results of the prior sniff.
RESOLUTION
The surest workaround is to save your file to a temporary location on your disk, and then to load it by using either the MSHTML IPersistFile interface or the IWebBrowser2Navigate() method.
Another technique is to change your HTML files to defeat bogus data sniffing. IPersistStreamInit is frequently used to load documents that are produced through an XSL Transform, and XSL templates sometimes do not use white space and carriage returns to separate tags. Judicious use of white space and carriage returns can help MSHTML properly detect the MIME type of your document. You can also break up large SCRIPT blocks into several smaller blocks, or break up large passages of text with <P>, <DIV>, or <SPAN> tags.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.REFERENCES
For more information, visit the following MSDN Web site:
Modification Type: | Major | Last Reviewed: | 6/29/2004 |
---|
Keywords: | kbbug kbnofix KB323569 |
---|
|