| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 { | 248 { |
| 249 Vector<String> headers; | 249 Vector<String> headers; |
| 250 headerValue.split(',', false, headers); | 250 headerValue.split(',', false, headers); |
| 251 for (unsigned headerCount = 0; headerCount < headers.size(); headerCount++)
{ | 251 for (unsigned headerCount = 0; headerCount < headers.size(); headerCount++)
{ |
| 252 String strippedHeader = headers[headerCount].stripWhiteSpace(); | 252 String strippedHeader = headers[headerCount].stripWhiteSpace(); |
| 253 if (!strippedHeader.isEmpty()) | 253 if (!strippedHeader.isEmpty()) |
| 254 headerSet.add(strippedHeader); | 254 headerSet.add(strippedHeader); |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 | 257 |
| 258 void extractCorsExposedHeaderNamesList(const ResourceResponse& response, HTTPHea
derSet& headerSet) |
| 259 { |
| 260 // If a response was fetched via a service worker, it will always have |
| 261 // corsExposedHeaderNames set, either from the Access-Control-Expose-Headers |
| 262 // header, or explicitly via foreign fetch. For requests that didn't come |
| 263 // from a service worker, foreign fetch doesn't apply so just parse the CORS |
| 264 // header. |
| 265 if (response.wasFetchedViaServiceWorker()) { |
| 266 for (const auto& header : response.corsExposedHeaderNames()) |
| 267 headerSet.add(header); |
| 268 return; |
| 269 } |
| 270 parseAccessControlExposeHeadersAllowList(response.httpHeaderField(HTTPNames:
:Access_Control_Expose_Headers), headerSet); |
| 271 } |
| 272 |
| 258 bool CrossOriginAccessControl::isLegalRedirectLocation(const KURL& requestURL, S
tring& errorDescription) | 273 bool CrossOriginAccessControl::isLegalRedirectLocation(const KURL& requestURL, S
tring& errorDescription) |
| 259 { | 274 { |
| 260 // CORS restrictions imposed on Location: URL -- http://www.w3.org/TR/cors/#
redirect-steps (steps 2 + 3.) | 275 // CORS restrictions imposed on Location: URL -- http://www.w3.org/TR/cors/#
redirect-steps (steps 2 + 3.) |
| 261 if (!SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(requestURL.protocol()
)) { | 276 if (!SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(requestURL.protocol()
)) { |
| 262 errorDescription = "The request was redirected to a URL ('" + requestURL
.getString() + "') which has a disallowed scheme for cross-origin requests."; | 277 errorDescription = "The request was redirected to a URL ('" + requestURL
.getString() + "') which has a disallowed scheme for cross-origin requests."; |
| 263 return false; | 278 return false; |
| 264 } | 279 } |
| 265 | 280 |
| 266 if (!(requestURL.user().isEmpty() && requestURL.pass().isEmpty())) { | 281 if (!(requestURL.user().isEmpty() && requestURL.pass().isEmpty())) { |
| 267 errorDescription = "The request was redirected to a URL ('" + requestURL
.getString() + "') containing userinfo, which is disallowed for cross-origin req
uests."; | 282 errorDescription = "The request was redirected to a URL ('" + requestURL
.getString() + "') containing userinfo, which is disallowed for cross-origin req
uests."; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 newRequest.setHTTPOrigin(securityOrigin); | 326 newRequest.setHTTPOrigin(securityOrigin); |
| 312 // If the user didn't request credentials in the first place, update our | 327 // If the user didn't request credentials in the first place, update our |
| 313 // state so we neither request them nor expect they must be allowed. | 328 // state so we neither request them nor expect they must be allowed. |
| 314 if (options.credentialsRequested == ClientDidNotRequestCredentials) | 329 if (options.credentialsRequested == ClientDidNotRequestCredentials) |
| 315 options.allowCredentials = DoNotAllowStoredCredentials; | 330 options.allowCredentials = DoNotAllowStoredCredentials; |
| 316 } | 331 } |
| 317 return true; | 332 return true; |
| 318 } | 333 } |
| 319 | 334 |
| 320 } // namespace blink | 335 } // namespace blink |
| OLD | NEW |