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 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 | 180 |
181 RefPtr<DocumentThreadableLoader> protect(this); | 181 RefPtr<DocumentThreadableLoader> protect(this); |
182 // Allow same origin requests to continue after allowing clients to audit th e redirect. | 182 // Allow same origin requests to continue after allowing clients to audit th e redirect. |
183 if (isAllowedRedirect(request.url())) { | 183 if (isAllowedRedirect(request.url())) { |
184 if (m_client->isDocumentThreadableLoaderClient()) | 184 if (m_client->isDocumentThreadableLoaderClient()) |
185 static_cast<DocumentThreadableLoaderClient*>(m_client)->willSendRequ est(request, redirectResponse); | 185 static_cast<DocumentThreadableLoaderClient*>(m_client)->willSendRequ est(request, redirectResponse); |
186 return; | 186 return; |
187 } | 187 } |
188 | 188 |
189 // When using access control, only simple cross origin requests are allowed to redirect. The new request URL must have a supported | 189 // When using access control, only simple cross origin requests are allowed to redirect. The new request URL must have a supported |
190 // scheme and not contain the userinfo production. In addition, the redirect response must pass the access control check. | 190 // scheme and not contain the userinfo production. In addition, the redirect response must pass the access control check if the |
191 // original request was not same-origin. | |
191 if (m_options.crossOriginRequestPolicy == UseAccessControl) { | 192 if (m_options.crossOriginRequestPolicy == UseAccessControl) { |
192 bool allowRedirect = false; | 193 bool allowRedirect = false; |
193 if (m_simpleRequest) { | 194 if (m_simpleRequest) { |
194 String accessControlErrorDescription; | 195 String accessControlErrorDescription; |
195 allowRedirect = SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(re quest.url().protocol()) | 196 allowRedirect = SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(re quest.url().protocol()) |
196 && request.url().user().isEmpty() | 197 && request.url().user().isEmpty() |
197 && request.url().pass().isEmpty() | 198 && request.url().pass().isEmpty() |
198 && passesAccessControlCheck(redirectResponse, m_opti ons.allowCredentials, securityOrigin(), accessControlErrorDescription); | 199 && (m_sameOriginRequest || passesAccessControlCheck( redirectResponse, m_options.allowCredentials, securityOrigin(), accessControlErr orDescription)); |
abarth-chromium
2013/05/09 04:22:06
Ah, I see. I was mis-reading the implementation o
| |
199 } | 200 } |
200 | 201 |
201 if (allowRedirect) { | 202 if (allowRedirect) { |
202 if (m_resource) | 203 if (m_resource) |
203 clearResource(); | 204 clearResource(); |
204 | 205 |
205 RefPtr<SecurityOrigin> originalOrigin = SecurityOrigin::createFromSt ring(redirectResponse.url()); | 206 RefPtr<SecurityOrigin> originalOrigin = SecurityOrigin::createFromSt ring(redirectResponse.url()); |
206 RefPtr<SecurityOrigin> requestOrigin = SecurityOrigin::createFromStr ing(request.url()); | 207 RefPtr<SecurityOrigin> requestOrigin = SecurityOrigin::createFromStr ing(request.url()); |
207 // If the request URL origin is not same origin with the original UR L origin, set source origin to a globally unique identifier. | 208 // If the request URL origin is not same origin with the original UR L origin, set source origin to a globally unique identifier. |
208 if (!originalOrigin->isSameSchemeHostPort(requestOrigin.get())) | 209 if (!originalOrigin->isSameSchemeHostPort(requestOrigin.get())) |
209 m_options.securityOrigin = SecurityOrigin::createUnique(); | 210 m_options.securityOrigin = SecurityOrigin::createUnique(); |
210 // Force any subsequent requests to use these checks. | 211 // Force any subsequent requests to use these checks. |
211 m_sameOriginRequest = false; | 212 m_sameOriginRequest = false; |
212 | 213 |
214 // Since the request is no longer same-origin, if the user didn't re quest credentials in | |
215 // the first place, update our state so we neither request them nor expect they must be allowed. | |
216 if (m_options.credentialsRequested == ClientDidNotRequestCredentials ) | |
217 m_options.allowCredentials = DoNotAllowStoredCredentials; | |
218 | |
213 // Remove any headers that may have been added by the network layer that cause access control to fail. | 219 // Remove any headers that may have been added by the network layer that cause access control to fail. |
214 request.clearHTTPContentType(); | 220 request.clearHTTPContentType(); |
215 request.clearHTTPReferrer(); | 221 request.clearHTTPReferrer(); |
216 request.clearHTTPOrigin(); | 222 request.clearHTTPOrigin(); |
217 request.clearHTTPUserAgent(); | 223 request.clearHTTPUserAgent(); |
218 request.clearHTTPAccept(); | 224 request.clearHTTPAccept(); |
219 makeCrossOriginAccessRequest(request); | 225 makeCrossOriginAccessRequest(request); |
220 return; | 226 return; |
221 } | 227 } |
222 } | 228 } |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 | 440 |
435 return m_sameOriginRequest && securityOrigin()->canRequest(url); | 441 return m_sameOriginRequest && securityOrigin()->canRequest(url); |
436 } | 442 } |
437 | 443 |
438 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const | 444 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const |
439 { | 445 { |
440 return m_options.securityOrigin ? m_options.securityOrigin.get() : m_documen t->securityOrigin(); | 446 return m_options.securityOrigin ? m_options.securityOrigin.get() : m_documen t->securityOrigin(); |
441 } | 447 } |
442 | 448 |
443 } // namespace WebCore | 449 } // namespace WebCore |
OLD | NEW |