OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013, Intel Corporation | 3 * Copyright (C) 2013, Intel Corporation |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // scheme and not contain the userinfo production. In addition, the redirect
response must pass the access control check if the | 192 // scheme and not contain the userinfo production. In addition, the redirect
response must pass the access control check if the |
193 // original request was not same-origin. | 193 // original request was not same-origin. |
194 if (m_options.crossOriginRequestPolicy == UseAccessControl) { | 194 if (m_options.crossOriginRequestPolicy == UseAccessControl) { |
195 | 195 |
196 InspectorInstrumentation::didReceiveCORSRedirectResponse(m_document->fra
me(), resource->identifier(), m_document->frame()->loader().documentLoader(), re
directResponse, 0); | 196 InspectorInstrumentation::didReceiveCORSRedirectResponse(m_document->fra
me(), resource->identifier(), m_document->frame()->loader().documentLoader(), re
directResponse, 0); |
197 | 197 |
198 bool allowRedirect = false; | 198 bool allowRedirect = false; |
199 String accessControlErrorDescription; | 199 String accessControlErrorDescription; |
200 | 200 |
201 if (m_simpleRequest) { | 201 if (m_simpleRequest) { |
202 allowRedirect = checkCrossOriginAccessRedirectionUrl(request.url(),
accessControlErrorDescription) | 202 allowRedirect = CrossOriginAccessControl::isLegalRedirectLocation(re
quest.url(), accessControlErrorDescription) |
203 && (m_sameOriginRequest || passesAccessControlCheck(
redirectResponse, m_options.allowCredentials, securityOrigin(), accessControlErr
orDescription)); | 203 && (m_sameOriginRequest || passesAccessControlCheck(
redirectResponse, m_options.allowCredentials, securityOrigin(), accessControlErr
orDescription)); |
204 } else { | 204 } else { |
205 accessControlErrorDescription = "The request was redirected to '"+ r
equest.url().string() + "', which is disallowed for cross-origin requests that r
equire preflight."; | 205 accessControlErrorDescription = "The request was redirected to '"+ r
equest.url().string() + "', which is disallowed for cross-origin requests that r
equire preflight."; |
206 } | 206 } |
207 | 207 |
208 if (allowRedirect) { | 208 if (allowRedirect) { |
| 209 // FIXME: consider combining this with CORS redirect handling perfor
med by |
| 210 // CrossOriginAccessControl::handleRedirect(). |
209 clearResource(); | 211 clearResource(); |
210 | 212 |
211 RefPtr<SecurityOrigin> originalOrigin = SecurityOrigin::create(redir
ectResponse.url()); | 213 RefPtr<SecurityOrigin> originalOrigin = SecurityOrigin::create(redir
ectResponse.url()); |
212 RefPtr<SecurityOrigin> requestOrigin = SecurityOrigin::create(reques
t.url()); | 214 RefPtr<SecurityOrigin> requestOrigin = SecurityOrigin::create(reques
t.url()); |
213 // If the original request wasn't same-origin, then if the request U
RL origin is not same origin with the original URL origin, | 215 // If the original request wasn't same-origin, then if the request U
RL origin is not same origin with the original URL origin, |
214 // set the source origin to a globally unique identifier. (If the or
iginal request was same-origin, the origin of the new request | 216 // set the source origin to a globally unique identifier. (If the or
iginal request was same-origin, the origin of the new request |
215 // should be the original URL origin.) | 217 // should be the original URL origin.) |
216 if (!m_sameOriginRequest && !originalOrigin->isSameSchemeHostPort(re
questOrigin.get())) | 218 if (!m_sameOriginRequest && !originalOrigin->isSameSchemeHostPort(re
questOrigin.get())) |
217 m_options.securityOrigin = SecurityOrigin::createUnique(); | 219 m_options.securityOrigin = SecurityOrigin::createUnique(); |
218 // Force any subsequent requests to use these checks. | 220 // Force any subsequent requests to use these checks. |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 if (m_options.contentSecurityPolicyEnforcement != EnforceConnectSrcDirective
) | 457 if (m_options.contentSecurityPolicyEnforcement != EnforceConnectSrcDirective
) |
456 return true; | 458 return true; |
457 return m_document->contentSecurityPolicy()->allowConnectToSource(url); | 459 return m_document->contentSecurityPolicy()->allowConnectToSource(url); |
458 } | 460 } |
459 | 461 |
460 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const | 462 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const |
461 { | 463 { |
462 return m_options.securityOrigin ? m_options.securityOrigin.get() : m_documen
t->securityOrigin(); | 464 return m_options.securityOrigin ? m_options.securityOrigin.get() : m_documen
t->securityOrigin(); |
463 } | 465 } |
464 | 466 |
465 bool DocumentThreadableLoader::checkCrossOriginAccessRedirectionUrl(const KURL&
requestUrl, String& errorDescription) | |
466 { | |
467 if (!SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(requestUrl.protocol()
)) { | |
468 errorDescription = "The request was redirected to a URL ('" + requestUrl
.string() + "') which has a disallowed scheme for cross-origin requests."; | |
469 return false; | |
470 } | |
471 | |
472 if (!(requestUrl.user().isEmpty() && requestUrl.pass().isEmpty())) { | |
473 errorDescription = "The request was redirected to a URL ('" + requestUrl
.string() + "') containing userinfo, which is disallowed for cross-origin reques
ts."; | |
474 return false; | |
475 } | |
476 | |
477 return true; | |
478 } | |
479 | |
480 } // namespace WebCore | 467 } // namespace WebCore |
OLD | NEW |