summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-07 23:59:06 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-07 23:59:06 +0000
commitee80b0759ec23970dd3a3d3ec237c437c2f0769e (patch)
tree1eeef8e25312b7c20dfe7460d81fad1dc27ea5e3 /net
parent2190bda779c8d83b3c52024fe676e189af696ac0 (diff)
downloadchromium_src-ee80b0759ec23970dd3a3d3ec237c437c2f0769e.zip
chromium_src-ee80b0759ec23970dd3a3d3ec237c437c2f0769e.tar.gz
chromium_src-ee80b0759ec23970dd3a3d3ec237c437c2f0769e.tar.bz2
Make sure that a null separates individual http headers when
we pickle them. BUG=7945 TEST=unittest. Review URL: http://codereview.chromium.org/113110 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15601 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/http/http_response_headers.cc5
-rw-r--r--net/http/http_response_headers_unittest.cc20
2 files changed, 23 insertions, 2 deletions
diff --git a/net/http/http_response_headers.cc b/net/http/http_response_headers.cc
index 59bd854..fb647ac 100644
--- a/net/http/http_response_headers.cc
+++ b/net/http/http_response_headers.cc
@@ -141,8 +141,9 @@ void HttpResponseHeaders::Persist(Pickle* pickle, PersistOptions options) {
StringToLowerASCII(&header_name);
if (filter_headers.find(header_name) == filter_headers.end()) {
- // Includes terminator null due to the + 1.
- blob.append(parsed_[i].name_begin, parsed_[k].value_end + 1);
+ // Make sure there is a null after the value.
+ blob.append(parsed_[i].name_begin, parsed_[k].value_end);
+ blob.push_back('\0');
}
i = k;
diff --git a/net/http/http_response_headers_unittest.cc b/net/http/http_response_headers_unittest.cc
index c6382aa7..24ca9869 100644
--- a/net/http/http_response_headers_unittest.cc
+++ b/net/http/http_response_headers_unittest.cc
@@ -423,6 +423,26 @@ TEST(HttpResponseHeadersTest, Persist) {
"HTTP/1.1 200 OK\n"
"Bar: 1\n"
},
+ // Test LWS at the end of a header.
+ { net::HttpResponseHeaders::PERSIST_ALL,
+ "HTTP/1.1 200 OK\n"
+ "Content-Length: 450 \n"
+ "Content-Encoding: gzip\n",
+
+ "HTTP/1.1 200 OK\n"
+ "Content-Length: 450\n"
+ "Content-Encoding: gzip\n"
+ },
+ // Test LWS at the end of a header.
+ { net::HttpResponseHeaders::PERSIST_RAW,
+ "HTTP/1.1 200 OK\n"
+ "Content-Length: 450 \n"
+ "Content-Encoding: gzip\n",
+
+ "HTTP/1.1 200 OK\n"
+ "Content-Length: 450\n"
+ "Content-Encoding: gzip\n"
+ },
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {