OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |