| Index: net/base/mime_sniffer.cc
|
| diff --git a/net/base/mime_sniffer.cc b/net/base/mime_sniffer.cc
|
| index 608f870cfed21ec047be1ea799c5c1aa898ba299..45f91b1e4eafa82f3d6777307b4c900eee48b95c 100644
|
| --- a/net/base/mime_sniffer.cc
|
| +++ b/net/base/mime_sniffer.cc
|
| @@ -552,6 +552,11 @@ static const MagicNumber kMagicXML[] = {
|
| MAGIC_STRING("application/rss+xml", "<rss"), // UTF-8
|
| };
|
|
|
| +static const MagicNumber kMagicXMLForApplicationXML[] = {
|
| + MAGIC_STRING("application/atom+xml", "<feed"),
|
| + MAGIC_STRING("application/rss+xml", "<rss"), // UTF-8
|
| +};
|
| +
|
| // Returns true and sets result if the content appears to contain XHTML or a
|
| // feed.
|
| // Clears have_enough_content if more data could possibly change the result.
|
| @@ -562,6 +567,7 @@ static const MagicNumber kMagicXML[] = {
|
| // of ASCII -- do we care?
|
| static bool SniffXML(const char* content,
|
| size_t size,
|
| + const std::string& type_hint,
|
| bool* have_enough_content,
|
| std::string* result) {
|
| // We allow at most 300 bytes of content before we expect the opening tag.
|
| @@ -600,9 +606,15 @@ static bool SniffXML(const char* content,
|
| continue;
|
| }
|
|
|
| - if (CheckForMagicNumbers(pos, end - pos, kMagicXML, arraysize(kMagicXML),
|
| - result))
|
| - return true;
|
| + if (type_hint == "application/xml") {
|
| + if (CheckForMagicNumbers(pos, end - pos, kMagicXMLForApplicationXML,
|
| + arraysize(kMagicXMLForApplicationXML), result))
|
| + return true;
|
| + } else {
|
| + if (CheckForMagicNumbers(pos, end - pos, kMagicXML, arraysize(kMagicXML),
|
| + result))
|
| + return true;
|
| + }
|
|
|
| // TODO(evanm): handle RSS 1.0, which is an RDF format and more difficult
|
| // to identify.
|
| @@ -822,7 +834,8 @@ bool SniffMimeType(const char* content,
|
| // We're not interested in sniffing these types for images and the like.
|
| // Instead, we're looking explicitly for a feed. If we don't find one
|
| // we're done and return early.
|
| - if (SniffXML(content, content_size, &have_enough_content, result))
|
| + if (SniffXML(content, content_size, type_hint, &have_enough_content,
|
| + result))
|
| return true;
|
| return have_enough_content;
|
| }
|
|
|