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.
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:
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
Comments
Anonymous
September 27, 2010
Great explanation! I do hope it will be fixed and will work. Thanks.Anonymous
September 27, 2010
Mark Russinovich -> Mr. Process Explorer -> investigates obscure Kernel/Win32 related issues -> fascinating blog post Eric Lawrence -> Mr. Fiddler -> investigates obscure Internet related issues -> fascinating blog post Nuff said!Anonymous
September 27, 2010
Thats an amazing post. Actually, I's wondering why the google images don't shows any images from page2 and so on, in ie9 beta. And thats a nice explanation, especially using the Fiddler. Thanks one again. :)Anonymous
September 27, 2010
The comment has been removedAnonymous
September 27, 2010
@Chad: The Google server is simply misconfigured. This misconfiguration would go unnoticed if Google wasn't sending the X-Content-Type-Options header. They've configured their server to return this header on all responses because it can improve security, however, as demonstrated here, it can also break your site if your MIME types are not set properly.Anonymous
February 15, 2011
I dont get gray squares. Instead, in IE9 i have old scool Google image search, not the new version. Chrome and FF are ok. Help! EricLaw: It sounds like Google is now using a browser version check and returning different content to IE9. You could verify using the F12 developer tools which allow you to change the user-agent string. But ultimately, you'll have to ask Google when they plan to fix this.Anonymous
September 25, 2011
The comment has been removedAnonymous
September 25, 2011
@Reid IE9 came out of beta six months ago. Perhaps it's time to upgrade...