Commit 8100d4b5 authored by Anand K. Mistry's avatar Anand K. Mistry Committed by Commit Bot

Add AMR to the MIME sniffer's list of extra magic numbers.

Shell scripts start with "#!", therefore the primary list of magic
numbers recognises these as text/plain. However, AMR files also start
with "#!", which causes them to be misidentified.

BUG=813059

Change-Id: Icabf35126053a0e65c4d3a45c663c9122eb4a7a9
Reviewed-on: https://chromium-review.googlesource.com/c/1348887Reviewed-by: default avatarAsanka Herath <asanka@chromium.org>
Commit-Queue: Anand Mistry <amistry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610748}
parent b2e8acdc
......@@ -229,6 +229,8 @@ static const MagicNumber kExtraMagicNumbers[] = {
MAGIC_NUMBER("application/x-shockwave-flash", "FWS"),
MAGIC_NUMBER("video/x-flv", "FLV"),
MAGIC_NUMBER("audio/x-flac", "fLaC"),
// Per https://tools.ietf.org/html/rfc3267#section-8.1
MAGIC_NUMBER("audio/amr", "#!AMR\n"),
// RAW image types.
MAGIC_NUMBER("image/x-canon-cr2", "II\x2a\x00\x10\x00\x00\x00CR"),
......
......@@ -456,6 +456,13 @@ TEST(MimeSnifferTest, AudioVideoTest) {
&mime_type));
EXPECT_EQ("audio/mpeg", mime_type);
mime_type.clear();
const char kAMRTestData[] =
"\x23\x21\x41\x4d\x52\x0a\x3c\x53\x0a\x7c\xe8\xb8\x41\xa5\x80\xca";
EXPECT_TRUE(SniffMimeTypeFromLocalData(kAMRTestData, sizeof(kAMRTestData) - 1,
&mime_type));
EXPECT_EQ("audio/amr", mime_type);
mime_type.clear();
}
TEST(MimeSnifferTest, ImageTest) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment