diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-10 22:36:42 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-10 22:36:42 +0000 |
commit | 07d212e60e60aa937f81cf0be686a4fb7997bfd4 (patch) | |
tree | 367252ce95c5d8ea66c01d0e9a192567ad4df175 | |
parent | 7f42929a1518c190fb3015bce9964a5ae416fb41 (diff) | |
download | chromium_src-07d212e60e60aa937f81cf0be686a4fb7997bfd4.zip chromium_src-07d212e60e60aa937f81cf0be686a4fb7997bfd4.tar.gz chromium_src-07d212e60e60aa937f81cf0be686a4fb7997bfd4.tar.bz2 |
This fixes another issue with PDF documents loaded via FastWebView (NPN_RequestRead). This would occur whenever Chrome was configured to use a proxy server. The NPN_RequestRead API sends out byte range requests to the server, which then responds with a HTTP Partial Response header (206) followed by a content type which specifies the boundary string which separates individual body parts.
We parse out the boundary string in our plugin implementation and then send out individual body parts to the plugin.
In this case the proxy server would respond to the byte range request and send back the response with a quoted boundary string. This is legit as per MIME specs. We did not handle this case and hence would look for the quoted boundary string in the data which did not exist.
Fix is to trim the leading and trailing quotes in the boundary string.
Added a unit test to handle this case.
Bug=http://code.google.com/p/chromium/issues/detail?id=4076
R=jam
Review URL: http://codereview.chromium.org/10236
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5132 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/glue/multipart_response_delegate.cc | 5 | ||||
-rw-r--r-- | webkit/glue/multipart_response_delegate_unittest.cc | 14 |
2 files changed, 18 insertions, 1 deletions
diff --git a/webkit/glue/multipart_response_delegate.cc b/webkit/glue/multipart_response_delegate.cc index 2c2b2b3..82e73e2 100644 --- a/webkit/glue/multipart_response_delegate.cc +++ b/webkit/glue/multipart_response_delegate.cc @@ -236,7 +236,6 @@ size_t MultipartResponseDelegate::FindBoundary() { bool MultipartResponseDelegate::ReadMultipartBoundary( const WebCore::ResourceResponse& response, std::string* multipart_boundary) { - WebCore::String content_type = response.httpHeaderField("Content-Type"); std::string content_type_as_string = webkit_glue::StringToStdString(content_type); @@ -258,6 +257,10 @@ bool MultipartResponseDelegate::ReadMultipartBoundary( *multipart_boundary = content_type_as_string.substr(boundary_start_offset, boundary_length); + // The byte range response can have quoted boundary strings. This is legal + // as per MIME specifications. Individual data fragements however don't + // contain quoted boundary strings. + TrimString(*multipart_boundary, "\"", multipart_boundary); return true; } diff --git a/webkit/glue/multipart_response_delegate_unittest.cc b/webkit/glue/multipart_response_delegate_unittest.cc index efe1a6e..e7d020c 100644 --- a/webkit/glue/multipart_response_delegate_unittest.cc +++ b/webkit/glue/multipart_response_delegate_unittest.cc @@ -439,6 +439,20 @@ TEST(MultipartResponseTest, MultipartByteRangeParsingTest) { response4, &multipart_boundary); EXPECT_EQ(result, true); EXPECT_EQ(string("--bound--"), multipart_boundary); + + ResourceResponse response5(KURL(), "multipart/byteranges", 0, "en-US", + String()); + response5.setHTTPHeaderField(String("Content-Length"), String("200")); + response5.setHTTPHeaderField( + String("Content-type"), + String("multipart/byteranges; boundary=\"--bound--\"; charSet=utf8")); + + multipart_boundary.clear(); + + result = MultipartResponseDelegate::ReadMultipartBoundary( + response5, &multipart_boundary); + EXPECT_EQ(result, true); + EXPECT_EQ(string("--bound--"), multipart_boundary); } TEST(MultipartResponseTest, MultipartContentRangesTest) { |