Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(826)

Unified Diff: third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp

Issue 1506803002: [XHR] Replace isSetCookieHeader() with isForbiddenResponseHeaderName() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
diff --git a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
index 8b302c8215b172312e8939667b77915e2f523e41..43a9adb7ecf072d4fb01546b994008a41b174120 100644
--- a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
+++ b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
@@ -100,11 +100,6 @@ private:
int* const m_level;
};
-bool isSetCookieHeader(const AtomicString& name)
-{
- return equalIgnoringCase(name, "set-cookie") || equalIgnoringCase(name, "set-cookie2");
-}
-
void replaceCharsetInMediaType(String& mediaType, const String& charsetValue)
{
unsigned pos = 0, len = 0;
@@ -1230,13 +1225,12 @@ String XMLHttpRequest::getAllResponseHeaders() const
parseAccessControlExposeHeadersAllowList(m_response.httpHeaderField("Access-Control-Expose-Headers"), accessControlExposeHeaderSet);
HTTPHeaderMap::const_iterator end = m_response.httpHeaderFields().end();
for (HTTPHeaderMap::const_iterator it = m_response.httpHeaderFields().begin(); it!= end; ++it) {
- // Hide Set-Cookie header fields from the XMLHttpRequest client for these reasons:
- // 1) If the client did have access to the fields, then it could read HTTP-only
- // cookies; those cookies are supposed to be hidden from scripts.
- // 2) There's no known harm in hiding Set-Cookie header fields entirely; we don't
- // know any widely used technique that requires access to them.
- // 3) Firefox has implemented this policy.
- if (isSetCookieHeader(it->key) && !securityOrigin()->canLoadLocalResources())
+ // Hide any headers whose name is a forbidden response-header name.
+ // This is required for all kinds of filtered responses.
+ //
+ // TODO: Consider removing canLoadLocalResources() call.
+ // crbug.com/567527
+ if (FetchUtils::isForbiddenResponseHeaderName(it->key) && !securityOrigin()->canLoadLocalResources())
continue;
if (!m_sameOriginRequest && !isOnAccessControlResponseHeaderWhitelist(it->key) && !accessControlExposeHeaderSet.contains(it->key))
@@ -1259,7 +1253,7 @@ const AtomicString& XMLHttpRequest::getResponseHeader(const AtomicString& name)
return nullAtom;
// See comment in getAllResponseHeaders above.
- if (isSetCookieHeader(name) && !securityOrigin()->canLoadLocalResources()) {
+ if (FetchUtils::isForbiddenResponseHeaderName(name) && !securityOrigin()->canLoadLocalResources()) {
logConsoleError(executionContext(), "Refused to get unsafe header \"" + name + "\"");
return nullAtom;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698