Google Image Search and IE9 Beta

One of the commonly reported bugs on Connect is that Google Image Search shows grey boxes for some of the images in IE9 Beta. I had a quick look at the site this afternoon, and I can easily reproduce the problem, as you can see in the screenshot below.

NoImagesForNoSniff

Now, I tend to debug things first from the network level, so I fired up my trusty HTTP debugger and observed the traffic as I scrolled the page. I quickly noticed something interesting:

image

Google appears to populate the images using a JSONP callback, which is basically a JavaScript file. However, the Content-Type reported by the server is text/plain. Now, from past debugging sessions, I know that Google tends to send their content with the response header X-Content-Type-Options: nosniff . This header instructs IE not to attempt to “sniff” the content-type of a HTTP response.

As I mentioned earlier this month, IE9 will not execute script if the HTTP response headers specify X-Content-Type-Options: nosniff and do not specify one of the following Content-Types: ["text/javascript", "application/javascript", "text/ecmascript", "application/ecmascript", "text/x-javascript", "application/x-javascript", "text/jscript", "text/vbscript", "text/vbs"].

In this case, the server has sent IE JavaScript, but indicated that the content is not script and further promises that the plaintext Content-Type is authoritative. Hence IE9 does not run the script, and as a result, the image boxes (which are populated by the script) are left empty.

Fiddler users can “fix” this problem themselves by clicking Rules > Customize Rules and adding the following Javascript

static function OnBeforeResponse(oSession: Session)
{
if (oSession.uriContains("jsonp") &&
(oSession.oResponse["Content-Type"] == "text/plain"))
{
oSession.oResponse["Content-Type"] = "text/javascript";
}

I sent a mail over to the Google team and I’m confident that this will be fixed shortly.

Thanks for trying the IE9 beta and sending us your feedback!

-Eric