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

Unified Diff: Source/core/loader/DocumentThreadableLoader.cpp

Issue 14557011: Fix problems with cross-origin redirects. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed typo in numbering in a test. Created 7 years, 7 months 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 | « Source/core/loader/DocumentLoader.cpp ('k') | Source/core/loader/ResourceLoaderOptions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/loader/DocumentThreadableLoader.cpp
diff --git a/Source/core/loader/DocumentThreadableLoader.cpp b/Source/core/loader/DocumentThreadableLoader.cpp
index 5ae09a9e4425100ef03d7b2dc89abfe7fe41b240..a40b7fc25a7795a0fea76b7fa93e75f50a41e4c0 100644
--- a/Source/core/loader/DocumentThreadableLoader.cpp
+++ b/Source/core/loader/DocumentThreadableLoader.cpp
@@ -187,7 +187,8 @@ void DocumentThreadableLoader::redirectReceived(CachedResource* resource, Resour
}
// When using access control, only simple cross origin requests are allowed to redirect. The new request URL must have a supported
- // scheme and not contain the userinfo production. In addition, the redirect response must pass the access control check.
+ // scheme and not contain the userinfo production. In addition, the redirect response must pass the access control check if the
+ // original request was not same-origin.
if (m_options.crossOriginRequestPolicy == UseAccessControl) {
bool allowRedirect = false;
if (m_simpleRequest) {
@@ -195,7 +196,7 @@ void DocumentThreadableLoader::redirectReceived(CachedResource* resource, Resour
allowRedirect = SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(request.url().protocol())
&& request.url().user().isEmpty()
&& request.url().pass().isEmpty()
- && passesAccessControlCheck(redirectResponse, m_options.allowCredentials, securityOrigin(), accessControlErrorDescription);
+ && (m_sameOriginRequest || passesAccessControlCheck(redirectResponse, m_options.allowCredentials, securityOrigin(), accessControlErrorDescription));
}
if (allowRedirect) {
@@ -204,12 +205,19 @@ void DocumentThreadableLoader::redirectReceived(CachedResource* resource, Resour
RefPtr<SecurityOrigin> originalOrigin = SecurityOrigin::createFromString(redirectResponse.url());
RefPtr<SecurityOrigin> requestOrigin = SecurityOrigin::createFromString(request.url());
- // If the request URL origin is not same origin with the original URL origin, set source origin to a globally unique identifier.
- if (!originalOrigin->isSameSchemeHostPort(requestOrigin.get()))
+ // If the original request wasn't same-origin, then if the request URL origin is not same origin with the original URL origin,
+ // set the source origin to a globally unique identifier. (If the original request was same-origin, the origin of the new request
+ // should be the original URL origin.)
+ if (!m_sameOriginRequest && !originalOrigin->isSameSchemeHostPort(requestOrigin.get()))
m_options.securityOrigin = SecurityOrigin::createUnique();
// Force any subsequent requests to use these checks.
m_sameOriginRequest = false;
+ // Since the request is no longer same-origin, if the user didn't request credentials in
+ // the first place, update our state so we neither request them nor expect they must be allowed.
+ if (m_options.credentialsRequested == ClientDidNotRequestCredentials)
+ m_options.allowCredentials = DoNotAllowStoredCredentials;
+
// Remove any headers that may have been added by the network layer that cause access control to fail.
request.clearHTTPContentType();
request.clearHTTPReferrer();
« no previous file with comments | « Source/core/loader/DocumentLoader.cpp ('k') | Source/core/loader/ResourceLoaderOptions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698