Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1067)

Unified Diff: net/base/mime_sniffer.cc

Issue 467035: Adjust our sniffing hueristics to better match Firefox.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/base/mime_sniffer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/mime_sniffer.cc
===================================================================
--- net/base/mime_sniffer.cc (revision 33907)
+++ net/base/mime_sniffer.cc (working copy)
@@ -73,8 +73,12 @@
// URL has an GIF extension)
// * Opera 9: Render as GIF
//
-// Given our previous decisions, this decision is more or less clear.
-// => Chrome: Render as GIF
+// We used to render as GIF here, but the problem is that some sites want to
+// trigger downloads by sending application/octet-stream (even though they
+// should be sending Content-Disposition: attachment). Although it is safe
+// to render as GIF from a security perspective, we actually get better
+// compatibility if we don't sniff from application/octet stream at all.
+// => Chrome: Download as application/octet-stream
//
// XHTML payload, Content-Type: "text/xml":
// * IE 7: Render as XML
@@ -492,9 +496,8 @@
// Many web servers are misconfigured to send text/plain for many
// different types of content.
"text/plain",
- // IIS 4.0 and 5.0 send application/octet-stream when serving .xhtml
- // files. Firefox 2.0 does not sniff xhtml here, but Safari 3,
- // Opera 9, and IE do.
+ // We want to sniff application/octet-stream for
+ // application/x-chrome-extension, but nothing else.
"application/octet-stream",
// XHTML and Atom/RSS feeds are often served as plain xml instead of
// their more specific mime types.
@@ -577,6 +580,11 @@
if (SniffCRX(content, content_size, url, type_hint, result))
return true;
+ // We're not interested in sniffing for magic numbers when the type_hint
+ // is application/octet-stream. Time to bail out.
+ if (type_hint == "application/octet-stream")
+ return have_enough_content;
+
// Now we look in our large table of magic numbers to see if we can find
// anything that matches the content.
if (SniffForMagicNumbers(content, content_size, result))
« no previous file with comments | « no previous file | net/base/mime_sniffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698