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

Unified Diff: net/base/mime_util.cc

Issue 1134393002: Implement ChromeOS mime type extension mappings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 7 months 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 | « net/base/mime_util.h ('k') | net/base/mime_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/mime_util.cc
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc
index 7db410ba0c9bf636ceee0feeeaf635bfaf7a1bbc..0438586568da0b7391ee7d0b051157abb7557795 100644
--- a/net/base/mime_util.cc
+++ b/net/base/mime_util.cc
@@ -164,11 +164,6 @@ class MimeUtil : public PlatformMimeUtil {
static base::LazyInstance<MimeUtil>::Leaky g_mime_util =
LAZY_INSTANCE_INITIALIZER;
-struct MimeInfo {
- const char* const mime_type;
- const char* const extensions; // comma separated list
-};
-
static const MimeInfo primary_mappings[] = {
{ "text/html", "html,htm,shtml,shtm" },
{ "text/css", "css" },
@@ -216,12 +211,11 @@ static const MimeInfo secondary_mappings[] = {
{ "application/pkcs7-mime", "p7m,p7c,p7z" },
{ "application/pkcs7-signature", "p7s" },
{ "application/x-mpegurl", "m3u8" },
- { "application/epub+zip", "epub" },
};
-static const char* FindMimeType(const MimeInfo* mappings,
- size_t mappings_len,
- const char* ext) {
+const char* FindMimeType(const MimeInfo* mappings,
+ size_t mappings_len,
+ const char* ext) {
size_t ext_len = strlen(ext);
for (size_t i = 0; i < mappings_len; ++i) {
@@ -268,6 +262,12 @@ bool MimeUtil::GetMimeTypeFromExtensionHelper(
if (ext.length() > kMaxFilePathSize)
return false;
+ // Reject a string which contains null character.
+ base::FilePath::StringType::size_type nul_pos =
+ ext.find(FILE_PATH_LITERAL('\0'));
+ if (nul_pos != base::FilePath::StringType::npos)
+ return false;
+
// We implement the same algorithm as Mozilla for mapping a file extension to
// a mime type. That is, we first check a hard-coded list (that cannot be
// overridden), and then if not found there, we defer to the system registry.
« no previous file with comments | « net/base/mime_util.h ('k') | net/base/mime_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698