XHTML in Mantis 1.3 development trunk

I just wanted to upgrade my current installation of Mantis to the current 1.3.0 trunk. But this wasn’t as easy as in previous development releases of mantis. Obviously the content-encoding switched to more strict xhtml+xml. In previous versions the HTTP content-type was still text/html, which worked just fine. Using Firefox is no problem, but Internet Explorer doesn’t like the content-type application/xhtml+xml and always tries to download the page instead of displaying the page.

To resolve this problem I added a test prior to sending the content type, to which content type is actually supported by the client. The content-type is set in thehttp_api.php, so the modified function http_content_headers() looks like this:

 * Set content-type headers.
function http_content_headers() {
    if ( !headers_sent() ) {
        if (stristr($_SERVER[HTTP_ACCEPT], "application/xhtml+xml")) {
            header( 'Content-Type: application/xhtml+xml; charset=UTF-8' );
        } else {
            header( 'Content-Type: text/html; charset=UTF-8' );
        // Disallow Internet Explorer from attempting to second guess the Content-Type
        // header as per http://blogs.msdn.com/ie/archive/2008/07/02/ie8-security-part-v-comprehensive-pro
        header( 'X-Content-Type-Options: nosniff' );

On another quick side-note: I had some custom HTML to include my own header to mantis, which caused an XML parse error – this was because I didn’t close the img tag for an embedded image.

Leave a Comment.