diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-17 21:43:20 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-17 21:43:20 +0000 |
commit | 8ef59c3b8d485227dae56a1ce4edc784be329f59 (patch) | |
tree | 68344d77979b8a468e5d2c95e3798b87adfd836d /net | |
parent | 4a324a1705813d626833e38539f3cc3bf27b2627 (diff) | |
download | chromium_src-8ef59c3b8d485227dae56a1ce4edc784be329f59.zip chromium_src-8ef59c3b8d485227dae56a1ce4edc784be329f59.tar.gz chromium_src-8ef59c3b8d485227dae56a1ce4edc784be329f59.tar.bz2 |
Fix problem where "text/xml" responses get buffered past 512 bytes, causing the response to be truncated.
BUG=3521
Review URL: http://codereview.chromium.org/7610
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3567 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/mime_sniffer.cc | 4 | ||||
-rw-r--r-- | net/base/mime_sniffer_unittest.cc | 13 |
2 files changed, 16 insertions, 1 deletions
diff --git a/net/base/mime_sniffer.cc b/net/base/mime_sniffer.cc index 53e765e..da117e2 100644 --- a/net/base/mime_sniffer.cc +++ b/net/base/mime_sniffer.cc @@ -529,7 +529,9 @@ bool SniffMimeType(const char* content, size_t content_size, // 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. - return SniffXML(content, content_size, result); + if (SniffXML(content, content_size, result)) + return true; + return content_size >= kMaxBytesToSniff; } // Now we look in our large table of magic numbers to see if we can find diff --git a/net/base/mime_sniffer_unittest.cc b/net/base/mime_sniffer_unittest.cc index 0ed87e8..caf258b 100644 --- a/net/base/mime_sniffer_unittest.cc +++ b/net/base/mime_sniffer_unittest.cc @@ -295,3 +295,16 @@ TEST(MimeSnifferTest, XMLTest) { } +// Test content which is >= 512 bytes, and includes no open angle bracket. +// http://code.google.com/p/chromium/issues/detail?id=3521 +TEST(MimeSnifferTest, XMLTestLargeNoAngledBracket) { + // Make a large input, with 600 bytes of "x". + std::string content; + content.resize(600); + std::fill(content.begin(), content.end(), 'x'); + + // content.size() >= kMaxBytesToSniff (512) so the sniff is unambiguous. + std::string mime_type; + EXPECT_TRUE(net::SniffMimeType(content.data(), content.size(), GURL(), + "text/xml", &mime_type)); +} |