Extension:MHTML

What can this extension do?
If MHTML text is pasted into a Wiki document between and tags, it will render the MHTML in an IFRAME. This permits including Powerpoint, word, etc... in Wiki pages (without losing the ability to further edit them in the original application) including those with Visio diagrams pasted into them.

Usage
Do not use this on public sites. When editing a page, use the clipboard to copy MHTML files into the Wiki edit page. Surround the MHTML with and. Page will render in an IFRAME. This facilitates placing documents, particularly from MS-OFFICE, into Wiki pages.

The extension will attempt to guess which HTML file should be considered the main page. To tell it, set the page attribute, for example

Download instructions
Please cut and paste the code found below and place it in. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installation
This extension requires the optional "mailparse" PECL module for php. Install according to the normal PECL procedures. However, mailparse must load AFTER mbstring. On many distributions, this is most easily ensured by changing the ini file for mailparse to "z-mailparse.ini" so it loads after "mbstring.ini".

To install this extension, add the following to LocalSettings.php:

Configuration parameters
None

User rights
None

Warnings, Bugs, and TODO

 * Do not use on any site where use of raw html would be unsafe
 * The unpacked contents of each mhtml file are placed in the images/cached directory in directories hashed with the MD5 of the original mhtml file. There is not yet any cleanup. If you delete them, you must make sure that the cached version of the module's output is also flushed.
 * Cutting and pasting MHTML files into the edit box is silly.  There should be a file upload dialog.
 * Some MHTML files, particularly from Powerpoint, do not display correctly in Firefox. Paste slides into Word documents to avoid this.
 * WARNING - there is not yet protection from path traversal attacks in the MHTML
 * TODO -- the "<base href=" text can wrap. The code that fixes this needs to be replaced with preg_replace.