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

Unified Diff: net/base/mime_sniffer.cc

Issue 465048: net: Ignore the magic number sniffer if it determines an application/octet-st... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: with additional comment 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 33698)
+++ net/base/mime_sniffer.cc (working copy)
@@ -579,8 +579,14 @@
// 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))
+ if (SniffForMagicNumbers(content, content_size, result)) {
+ // We should never sniff an octet stream as plain text. There are Unix
+ // binaries with embedded shell scripts that get sniffed incorrectly,
+ // leading to spectacular failures like bug 29354.
+ if (type_hint == "application/octet-stream" && "text/plain" == *result)
+ result->assign("application/octet-stream");
return true; // We've matched a magic number. No more content needed.
+ }
// Having failed thus far, we're willing to override unknown mime types and
// text/plain.
« 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