Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

Time to fix those broken pages

I have a whole bunch of gripes about Internet Explorer, but my personal favourite is the way it will render a document served with a text/plain Content-Type header if it thinks the file might contain HTML. The direct result of this is that people with misconfigured web servers who are serving their HTML with the wrong Content-Type frequently don’t realise, so when users of better behaved browsers such as FireFox visit they get hit in the face with a page of raw source code.

The times they are a-changing. I just spotted this gem in MSDN’s article How to Make Your Web Site Work with Windows XP Service Pack 2:

Q: Does your Web site contain files with file types that do not match their Content-Type and/or file extension?

A: You should correct all of these mismatches. Both the Content-Type and the file extension must match the type of the file for a download prompt to appear. Be sure this is true for your Web pages as well. If the Content-Type is plain/text, then they will not render as HTML.

Of course, the rate at which people upgrade to service pack 2 is likely to be pretty poor but at least new machines will have it installed by default. Hopefully sites serving the wrong Content-Type for their HTML documents will be forced to clean up pretty quickly.

The other issue mentioned in that quotation—forcing the file extension to match the Content-Type—is a little odd from a non-Windows OS point of view but I’m sure there’s a rational reason behind it. At the end of the day, anything that improves Windows security is a good thing for the health of both the Internet and society in general.

This is Time to fix those broken pages by Simon Willison, posted on 29th May 2004.

View blog reactions

Next: plinks - a purple numbers variant

Previous: Executing JavaScript on page load

6 comments

  1. plain/text? Coupled with the comment about file extensions, one would almost think MS isn't familiar with content types at all. I'd be tempted to change every .html extension on my site to .exe... that is, if I didn't already have Cool URIs.

    Peter J. - 30th May 2004 02:31 - #

  2. Eureka! I'd often wondered what was going wrong when a site's source code is displayed in place of a the web-page it describes.

    How on earth do these webmasters remain employed?

    DarkBlue - 30th May 2004 03:29 - #

  3. What is a correct extension? .asp, .php, .php3, .jsp, ...?

    There's thousands an thousands of extensions used for dinamic pages.

    There's a lot of not-very-popular-extensions used by not-very-popular-programming-languages.

    I think that the use of the extension in a distributed, OS independent plataform (The Web) has no sense.

    Joan Fisbein - 31st May 2004 15:03 - #

  4. You're being sarcastic, right? Forcing extensions to match is idiotic. They should follow the spec and rely on the HTTP header. It's annoying that since IE checks the extension, sysadmins around the globe don't change the Content type that WMV files are delivered as. That's why we get pages full of garbage in real browsers. One last time: Content type is authoritative.

    Joe W. - 31st May 2004 23:29 - #

  5. I am always amazed when people suggest that IE shouldn't do something in a particular way. Clearly these people are clueless, if IE didn't do it that way, millions of people would have other problems, which Simon and people like him have no idea about. I think they should leave software engineering to those who know. Trying to teach Microsoft how to write software is like trying to teach Einstein E=MC2 theory with all sorts of stupidities. Simon, get a life and stop acting like a fool, or at least act like a fool on slashdot, this way nobody will recognize you.

    Alex - 1st June 2004 12:35 - #

  6. ...Said the man with no link.

    Ah, yes, Alex, let's base a very complicated and open system on the whims of applications created by a corporate power.

    That, surely, is the smartest thing to do.

    Jeremy Dunck - 1st June 2004 16:28 - #

Comments are closed.

Previously hosted at http://simon.incutio.com/archive/2004/05/29/fix

A django site