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

Side by Side Diff: net/base/mime_util.cc

Issue 2962017: Merge 52130 - Fixes a crash when xdg_mime library is unable to handle a long ... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/375/src/
Patch Set: Created 10 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "net/base/mime_util.h" 7 #include "net/base/mime_util.h"
8 #include "net/base/platform_mime_util.h" 8 #include "net/base/platform_mime_util.h"
9 9
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 if (!*extensions) 120 if (!*extensions)
121 break; 121 break;
122 extensions += 1; // skip over comma 122 extensions += 1; // skip over comma
123 } 123 }
124 } 124 }
125 return NULL; 125 return NULL;
126 } 126 }
127 127
128 bool MimeUtil::GetMimeTypeFromExtension(const FilePath::StringType& ext, 128 bool MimeUtil::GetMimeTypeFromExtension(const FilePath::StringType& ext,
129 string* result) const { 129 string* result) const {
130 // Avoids crash when unable to handle a long file path. See crbug.com/48733.
131 const unsigned kMaxFilePathSize = 65536;
132 if (ext.length() > kMaxFilePathSize)
133 return false;
134
130 // We implement the same algorithm as Mozilla for mapping a file extension to 135 // We implement the same algorithm as Mozilla for mapping a file extension to
131 // a mime type. That is, we first check a hard-coded list (that cannot be 136 // a mime type. That is, we first check a hard-coded list (that cannot be
132 // overridden), and then if not found there, we defer to the system registry. 137 // overridden), and then if not found there, we defer to the system registry.
133 // Finally, we scan a secondary hard-coded list to catch types that we can 138 // Finally, we scan a secondary hard-coded list to catch types that we can
134 // deduce but that we also want to allow the OS to override. 139 // deduce but that we also want to allow the OS to override.
135 140
136 #if defined(OS_WIN) 141 #if defined(OS_WIN)
137 string ext_narrow_str = WideToUTF8(ext); 142 string ext_narrow_str = WideToUTF8(ext);
138 #elif defined(OS_POSIX) 143 #elif defined(OS_POSIX)
139 const string& ext_narrow_str = ext; 144 const string& ext_narrow_str = ext;
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 bool AreSupportedMediaCodecs(const std::vector<std::string>& codecs) { 452 bool AreSupportedMediaCodecs(const std::vector<std::string>& codecs) {
448 return GetMimeUtil()->AreSupportedMediaCodecs(codecs); 453 return GetMimeUtil()->AreSupportedMediaCodecs(codecs);
449 } 454 }
450 455
451 void ParseCodecString(const std::string& codecs, 456 void ParseCodecString(const std::string& codecs,
452 std::vector<std::string>* codecs_out) { 457 std::vector<std::string>* codecs_out) {
453 GetMimeUtil()->ParseCodecString(codecs, codecs_out); 458 GetMimeUtil()->ParseCodecString(codecs, codecs_out);
454 } 459 }
455 460
456 } // namespace net 461 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698