| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Detecting mime types is a tricky business because we need to balance | 5 // Detecting mime types is a tricky business because we need to balance |
| 6 // compatibility concerns with security issues. Here is a survey of how other | 6 // compatibility concerns with security issues. Here is a survey of how other |
| 7 // browsers behave and then a description of how we intend to behave. | 7 // browsers behave and then a description of how we intend to behave. |
| 8 // | 8 // |
| 9 // HTML payload, no Content-Type header: | 9 // HTML payload, no Content-Type header: |
| 10 // * IE 7: Render as HTML | 10 // * IE 7: Render as HTML |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 MAGIC_NUMBER("application/x-gzip", "\x1F\x8B\x08") | 155 MAGIC_NUMBER("application/x-gzip", "\x1F\x8B\x08") |
| 156 MAGIC_NUMBER("audio/x-pn-realaudio", "\x2E\x52\x4D\x46") | 156 MAGIC_NUMBER("audio/x-pn-realaudio", "\x2E\x52\x4D\x46") |
| 157 MAGIC_NUMBER("video/x-ms-asf", | 157 MAGIC_NUMBER("video/x-ms-asf", |
| 158 "\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C") | 158 "\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C") |
| 159 MAGIC_NUMBER("image/tiff", "I I") | 159 MAGIC_NUMBER("image/tiff", "I I") |
| 160 MAGIC_NUMBER("image/tiff", "II*") | 160 MAGIC_NUMBER("image/tiff", "II*") |
| 161 MAGIC_NUMBER("image/tiff", "MM\x00*") | 161 MAGIC_NUMBER("image/tiff", "MM\x00*") |
| 162 MAGIC_NUMBER("audio/mpeg", "ID3") | 162 MAGIC_NUMBER("audio/mpeg", "ID3") |
| 163 MAGIC_NUMBER("image/webp", "RIFF....WEBPVP8 ") | 163 MAGIC_NUMBER("image/webp", "RIFF....WEBPVP8 ") |
| 164 MAGIC_NUMBER("video/webm", "\x1A\x45\xDF\xA3") | 164 MAGIC_NUMBER("video/webm", "\x1A\x45\xDF\xA3") |
| 165 // TODO(abarth): we don't handle partial byte matches yet | |
| 166 // MAGIC_NUMBER("video/mpeg", "\x00\x00\x01\xB") | |
| 167 // MAGIC_NUMBER("audio/mpeg", "\xFF\xE") | |
| 168 // MAGIC_NUMBER("audio/mpeg", "\xFF\xF") | |
| 169 MAGIC_NUMBER("application/zip", "PK\x03\x04") | 165 MAGIC_NUMBER("application/zip", "PK\x03\x04") |
| 170 MAGIC_NUMBER("application/x-rar-compressed", "Rar!\x1A\x07\x00") | 166 MAGIC_NUMBER("application/x-rar-compressed", "Rar!\x1A\x07\x00") |
| 171 MAGIC_NUMBER("application/x-msmetafile", "\xD7\xCD\xC6\x9A") | 167 MAGIC_NUMBER("application/x-msmetafile", "\xD7\xCD\xC6\x9A") |
| 172 MAGIC_NUMBER("application/octet-stream", "MZ") // EXE | 168 MAGIC_NUMBER("application/octet-stream", "MZ") // EXE |
| 173 // Sniffing for Flash: | 169 // Sniffing for Flash: |
| 174 // | 170 // |
| 175 // MAGIC_NUMBER("application/x-shockwave-flash", "CWS") | 171 // MAGIC_NUMBER("application/x-shockwave-flash", "CWS") |
| 176 // MAGIC_NUMBER("application/x-shockwave-flash", "FLV") | 172 // MAGIC_NUMBER("application/x-shockwave-flash", "FLV") |
| 177 // MAGIC_NUMBER("application/x-shockwave-flash", "FWS") | 173 // MAGIC_NUMBER("application/x-shockwave-flash", "FWS") |
| 178 // | 174 // |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 // First check the extra table. | 959 // First check the extra table. |
| 964 if (CheckForMagicNumbers(content, size, kExtraMagicNumbers, | 960 if (CheckForMagicNumbers(content, size, kExtraMagicNumbers, |
| 965 arraysize(kExtraMagicNumbers), NULL, result)) | 961 arraysize(kExtraMagicNumbers), NULL, result)) |
| 966 return true; | 962 return true; |
| 967 // Finally check the original table. | 963 // Finally check the original table. |
| 968 return CheckForMagicNumbers(content, size, kMagicNumbers, | 964 return CheckForMagicNumbers(content, size, kMagicNumbers, |
| 969 arraysize(kMagicNumbers), NULL, result); | 965 arraysize(kMagicNumbers), NULL, result); |
| 970 } | 966 } |
| 971 | 967 |
| 972 } // namespace net | 968 } // namespace net |
| OLD | NEW |