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

Side by Side Diff: Source/core/loader/CrossOriginAccessControl.cpp

Issue 20735002: CORS: Fix the handling of redirected request containing Origin null. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 5 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 unified diff | Download patch
« no previous file with comments | « LayoutTests/http/tests/xmlhttprequest/resources/redirect-cors-origin-null-pass.php ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 { 139 {
140 AtomicallyInitializedStatic(AtomicString&, accessControlAllowOrigin = *new A tomicString("access-control-allow-origin", AtomicString::ConstructFromLiteral)); 140 AtomicallyInitializedStatic(AtomicString&, accessControlAllowOrigin = *new A tomicString("access-control-allow-origin", AtomicString::ConstructFromLiteral));
141 AtomicallyInitializedStatic(AtomicString&, accessControlAllowCredentials = * new AtomicString("access-control-allow-credentials", AtomicString::ConstructFrom Literal)); 141 AtomicallyInitializedStatic(AtomicString&, accessControlAllowCredentials = * new AtomicString("access-control-allow-credentials", AtomicString::ConstructFrom Literal));
142 142
143 // A wildcard Access-Control-Allow-Origin can not be used if credentials are to be sent, 143 // A wildcard Access-Control-Allow-Origin can not be used if credentials are to be sent,
144 // even with Access-Control-Allow-Credentials set to true. 144 // even with Access-Control-Allow-Credentials set to true.
145 const String& accessControlOriginString = response.httpHeaderField(accessCon trolAllowOrigin); 145 const String& accessControlOriginString = response.httpHeaderField(accessCon trolAllowOrigin);
146 if (accessControlOriginString == "*" && includeCredentials == DoNotAllowStor edCredentials) 146 if (accessControlOriginString == "*" && includeCredentials == DoNotAllowStor edCredentials)
147 return true; 147 return true;
148 148
149 if (securityOrigin->isUnique()) {
150 errorDescription = "Cannot make any requests from " + securityOrigin->to String() + ".";
151 return false;
152 }
153
154 // FIXME: Access-Control-Allow-Origin can contain a list of origins. 149 // FIXME: Access-Control-Allow-Origin can contain a list of origins.
155 if (accessControlOriginString != securityOrigin->toString()) { 150 if (accessControlOriginString != securityOrigin->toString()) {
156 if (accessControlOriginString == "*") 151 if (accessControlOriginString == "*")
157 errorDescription = "Cannot use wildcard in Access-Control-Allow-Orig in when credentials flag is true."; 152 errorDescription = "Cannot use wildcard in Access-Control-Allow-Orig in when credentials flag is true.";
158 else 153 else
159 errorDescription = "Origin " + securityOrigin->toString() + " is no t allowed by Access-Control-Allow-Origin."; 154 errorDescription = "Origin " + securityOrigin->toString() + " is no t allowed by Access-Control-Allow-Origin.";
160 return false; 155 return false;
161 } 156 }
162 157
163 if (includeCredentials == AllowStoredCredentials) { 158 if (includeCredentials == AllowStoredCredentials) {
(...skipping 12 matching lines...) Expand all
176 Vector<String> headers; 171 Vector<String> headers;
177 headerValue.split(',', false, headers); 172 headerValue.split(',', false, headers);
178 for (unsigned headerCount = 0; headerCount < headers.size(); headerCount++) { 173 for (unsigned headerCount = 0; headerCount < headers.size(); headerCount++) {
179 String strippedHeader = headers[headerCount].stripWhiteSpace(); 174 String strippedHeader = headers[headerCount].stripWhiteSpace();
180 if (!strippedHeader.isEmpty()) 175 if (!strippedHeader.isEmpty())
181 headerSet.add(strippedHeader); 176 headerSet.add(strippedHeader);
182 } 177 }
183 } 178 }
184 179
185 } // namespace WebCore 180 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/xmlhttprequest/resources/redirect-cors-origin-null-pass.php ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698