diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-06 00:04:01 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-06 00:04:01 +0000 |
commit | d0759395d231633ac65dc89c580373d7176e0661 (patch) | |
tree | 51cba672036b2709cb6622701dafbb592c7dcaab /webkit | |
parent | 5b10348cf8be7f63bc2a57ee1caeacfd4a5b97e0 (diff) | |
download | chromium_src-d0759395d231633ac65dc89c580373d7176e0661.zip chromium_src-d0759395d231633ac65dc89c580373d7176e0661.tar.gz chromium_src-d0759395d231633ac65dc89c580373d7176e0661.tar.bz2 |
This fixes bug http://code.google.com/p/chromium/issues/detail?id=4076, which was a hang while loading certain PDF files. This was a regression caused by support for NPN_RequestRead (PDF Fast Webview). We had incorrectly assumed that the Content Type showing up for partial HTTP Responses would always end with the boundary. A content type can show up like multipart/byteranges; boundary=--bound--; charSet=utf8. As a result we would look for the wrong boundary in the actual data resulting in a hang.
The parsing code now accounts for this. Added a unit test to test this case.
Bug=4076
R=jam
Review URL: http://codereview.chromium.org/9198
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4842 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/multipart_response_delegate.cc | 7 | ||||
-rw-r--r-- | webkit/glue/multipart_response_delegate_unittest.cc | 14 |
2 files changed, 20 insertions, 1 deletions
diff --git a/webkit/glue/multipart_response_delegate.cc b/webkit/glue/multipart_response_delegate.cc index 72d4158..2c2b2b3 100644 --- a/webkit/glue/multipart_response_delegate.cc +++ b/webkit/glue/multipart_response_delegate.cc @@ -247,7 +247,12 @@ bool MultipartResponseDelegate::ReadMultipartBoundary( } boundary_start_offset += strlen("boundary="); - size_t boundary_end_offset = content_type.length(); + + size_t boundary_end_offset = + content_type_as_string.find(';', boundary_start_offset); + + if (boundary_end_offset == std::string::npos) + boundary_end_offset = content_type_as_string.length(); size_t boundary_length = boundary_end_offset - boundary_start_offset; diff --git a/webkit/glue/multipart_response_delegate_unittest.cc b/webkit/glue/multipart_response_delegate_unittest.cc index 93bfcb2..efe1a6e 100644 --- a/webkit/glue/multipart_response_delegate_unittest.cc +++ b/webkit/glue/multipart_response_delegate_unittest.cc @@ -425,6 +425,20 @@ TEST(MultipartResponseTest, MultipartByteRangeParsingTest) { response3, &multipart_boundary); EXPECT_EQ(result, false); EXPECT_EQ(multipart_boundary.length(), 0U); + + ResourceResponse response4(KURL(), "multipart/byteranges", 0, "en-US", + String()); + response4.setHTTPHeaderField(String("Content-Length"), String("200")); + response4.setHTTPHeaderField( + String("Content-type"), + String("multipart/byteranges; boundary=--bound--; charSet=utf8")); + + multipart_boundary.clear(); + + result = MultipartResponseDelegate::ReadMultipartBoundary( + response4, &multipart_boundary); + EXPECT_EQ(result, true); + EXPECT_EQ(string("--bound--"), multipart_boundary); } TEST(MultipartResponseTest, MultipartContentRangesTest) { |