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

Unified Diff: Source/core/fetch/ResourceLoader.cpp

Issue 146853003: Correctly handle CORS access checks over cache-validating responses. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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 | « LayoutTests/http/tests/security/script-crossorigin-loads-cross-origin-conditional-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/ResourceLoader.cpp
diff --git a/Source/core/fetch/ResourceLoader.cpp b/Source/core/fetch/ResourceLoader.cpp
index 1ad15e7919e908f23367c022ecdaba8afc063e31..0d2d6c42ed04fc51e7f457bb0548394533e55709 100644
--- a/Source/core/fetch/ResourceLoader.cpp
+++ b/Source/core/fetch/ResourceLoader.cpp
@@ -313,8 +313,15 @@ void ResourceLoader::didReceiveResponse(blink::WebURLLoader*, const blink::WebUR
const ResourceResponse& resourceResponse = response.toResourceResponse();
if (responseNeedsAccessControlCheck()) {
- m_resource->setResponse(resourceResponse);
- if (!m_host->canAccessResource(m_resource, response.url())) {
+ // If the response successfully validated a cached resource, perform
+ // the access control with respect to it. Need to do this right here
+ // before the resource switches clients over to that validated resource.
+ Resource* resource = m_resource;
+ if (resource->isCacheValidator() && resourceResponse.httpStatusCode() == 304)
+ resource = m_resource->resourceToRevalidate();
+ else
+ m_resource->setResponse(resourceResponse);
+ if (!m_host->canAccessResource(resource, response.url())) {
cancel();
return;
}
« no previous file with comments | « LayoutTests/http/tests/security/script-crossorigin-loads-cross-origin-conditional-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698