summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordavidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-09 23:27:55 +0000
committerdavidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-09 23:27:55 +0000
commitabd5b932ba098c909ae8a7aebc4e3f3b3df1d15a (patch)
treefb87c2df2f25f8bcc1e62c9e1d167816a0b330f7 /webkit
parent6f9e13bdccb6a2a135dcc8fb641acb88637ac823 (diff)
downloadchromium_src-abd5b932ba098c909ae8a7aebc4e3f3b3df1d15a.zip
chromium_src-abd5b932ba098c909ae8a7aebc4e3f3b3df1d15a.tar.gz
chromium_src-abd5b932ba098c909ae8a7aebc4e3f3b3df1d15a.tar.bz2
Treat headers and HTTP status text as Latin-1
We currently decode them as UTF-8, but they should be interpreted as Latin-1. (XHR specs the relevant parameters as WebIDL ByteString.) For response headers, this matches Firefox, IE, Opera 12, and Safari. For status text, this matches Firefox nightly, IE, Opera 12, and Opera. For request headers, this matches Firefox nightly, Opera 12, and Safari. Preparatory Blink CL disabled a layout test: https://src.chromium.org/viewvc/blink?revision=157238&view=revision This CL will be followed by a Blink CL to fix and re-enable the test, throw exception on non-Latin-1 setRequestHeader argument, and add a new layout test to verify this behavior. BUG=276769 Review URL: https://chromiumcodereview.appspot.com/23553007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222127 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/child/weburlloader_impl.cc41
1 files changed, 20 insertions, 21 deletions
diff --git a/webkit/child/weburlloader_impl.cc b/webkit/child/weburlloader_impl.cc
index 1fdaad0..b7ea619 100644
--- a/webkit/child/weburlloader_impl.cc
+++ b/webkit/child/weburlloader_impl.cc
@@ -71,14 +71,13 @@ class HeaderFlattener : public WebHTTPHeaderVisitor {
}
virtual void visitHeader(const WebString& name, const WebString& value) {
- // TODO(darin): is UTF-8 really correct here? It is if the strings are
- // already ASCII (i.e., if they are already escaped properly).
- const std::string& name_utf8 = name.utf8();
- const std::string& value_utf8 = value.utf8();
+ // Headers are latin1.
+ const std::string& name_latin1 = name.latin1();
+ const std::string& value_latin1 = value.latin1();
// Skip over referrer headers found in the header map because we already
// pulled it out as a separate parameter.
- if (LowerCaseEqualsASCII(name_utf8, "referer"))
+ if (LowerCaseEqualsASCII(name_latin1, "referer"))
return;
// Skip over "Cache-Control: max-age=0" header if the corresponding
@@ -87,16 +86,16 @@ class HeaderFlattener : public WebHTTPHeaderVisitor {
// implementation will add the necessary headers based on load flags.
// See http://code.google.com/p/chromium/issues/detail?id=3434.
if ((load_flags_ & net::LOAD_VALIDATE_CACHE) &&
- LowerCaseEqualsASCII(name_utf8, "cache-control") &&
- LowerCaseEqualsASCII(value_utf8, "max-age=0"))
+ LowerCaseEqualsASCII(name_latin1, "cache-control") &&
+ LowerCaseEqualsASCII(value_latin1, "max-age=0"))
return;
- if (LowerCaseEqualsASCII(name_utf8, "accept"))
+ if (LowerCaseEqualsASCII(name_latin1, "accept"))
has_accept_header_ = true;
if (!buffer_.empty())
buffer_.append("\r\n");
- buffer_.append(name_utf8 + ": " + value_utf8);
+ buffer_.append(name_latin1 + ": " + value_latin1);
}
const std::string& GetBuffer() {
@@ -224,26 +223,26 @@ void PopulateURLResponse(
WebHTTPLoadInfo load_info;
load_info.setHTTPStatusCode(info.devtools_info->http_status_code);
- load_info.setHTTPStatusText(WebString::fromUTF8(
+ load_info.setHTTPStatusText(WebString::fromLatin1(
info.devtools_info->http_status_text));
load_info.setEncodedDataLength(info.encoded_data_length);
- load_info.setRequestHeadersText(WebString::fromUTF8(
+ load_info.setRequestHeadersText(WebString::fromLatin1(
info.devtools_info->request_headers_text));
- load_info.setResponseHeadersText(WebString::fromUTF8(
+ load_info.setResponseHeadersText(WebString::fromLatin1(
info.devtools_info->response_headers_text));
const HeadersVector& request_headers = info.devtools_info->request_headers;
for (HeadersVector::const_iterator it = request_headers.begin();
it != request_headers.end(); ++it) {
- load_info.addRequestHeader(WebString::fromUTF8(it->first),
- WebString::fromUTF8(it->second));
+ load_info.addRequestHeader(WebString::fromLatin1(it->first),
+ WebString::fromLatin1(it->second));
}
const HeadersVector& response_headers =
info.devtools_info->response_headers;
for (HeadersVector::const_iterator it = response_headers.begin();
it != response_headers.end(); ++it) {
- load_info.addResponseHeader(WebString::fromUTF8(it->first),
- WebString::fromUTF8(it->second));
+ load_info.addResponseHeader(WebString::fromLatin1(it->first),
+ WebString::fromLatin1(it->second));
}
response->setHTTPLoadInfo(load_info);
}
@@ -261,7 +260,7 @@ void PopulateURLResponse(
version = WebURLResponse::HTTP_1_1;
response->setHTTPVersion(version);
response->setHTTPStatusCode(headers->response_code());
- response->setHTTPStatusText(WebString::fromUTF8(headers->GetStatusText()));
+ response->setHTTPStatusText(WebString::fromLatin1(headers->GetStatusText()));
// TODO(darin): We should leverage HttpResponseHeaders for this, and this
// should be using the same code as ResourceDispatcherHost.
@@ -285,8 +284,8 @@ void PopulateURLResponse(
void* iter = NULL;
std::string name;
while (headers->EnumerateHeaderLines(&iter, &name, &value)) {
- response->addHTTPHeaderField(WebString::fromUTF8(name),
- WebString::fromUTF8(value));
+ response->addHTTPHeaderField(WebString::fromLatin1(name),
+ WebString::fromLatin1(value));
}
}
@@ -435,8 +434,8 @@ void WebURLLoaderImpl::Context::Start(
}
GURL referrer_url(
- request.httpHeaderField(WebString::fromUTF8("Referer")).utf8());
- const std::string& method = request.httpMethod().utf8();
+ request.httpHeaderField(WebString::fromUTF8("Referer")).latin1());
+ const std::string& method = request.httpMethod().latin1();
int load_flags = net::LOAD_NORMAL;
switch (request.cachePolicy()) {