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

Side by Side Diff: net/http/http_security_headers.cc

Issue 1172753003: Move LowerCaseEqualsASCII to base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util
Patch Set: Created 5 years, 6 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 | « net/http/http_response_headers.cc ('k') | net/http/http_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/base64.h" 5 #include "base/base64.h"
6 #include "base/basictypes.h" 6 #include "base/basictypes.h"
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_tokenizer.h" 8 #include "base/strings/string_tokenizer.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "net/http/http_security_headers.h" 10 #include "net/http/http_security_headers.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 tokenizer.set_options(base::StringTokenizer::RETURN_DELIMS); 192 tokenizer.set_options(base::StringTokenizer::RETURN_DELIMS);
193 tokenizer.set_quote_chars("\""); 193 tokenizer.set_quote_chars("\"");
194 std::string unquoted; 194 std::string unquoted;
195 while (tokenizer.GetNext()) { 195 while (tokenizer.GetNext()) {
196 DCHECK(!tokenizer.token_is_delim() || tokenizer.token().length() == 1); 196 DCHECK(!tokenizer.token_is_delim() || tokenizer.token().length() == 1);
197 switch (state) { 197 switch (state) {
198 case START: 198 case START:
199 case DIRECTIVE_END: 199 case DIRECTIVE_END:
200 if (IsAsciiWhitespace(*tokenizer.token_begin())) 200 if (IsAsciiWhitespace(*tokenizer.token_begin()))
201 continue; 201 continue;
202 if (LowerCaseEqualsASCII(tokenizer.token(), "max-age")) { 202 if (base::LowerCaseEqualsASCII(tokenizer.token(), "max-age")) {
203 state = AFTER_MAX_AGE_LABEL; 203 state = AFTER_MAX_AGE_LABEL;
204 max_age_observed++; 204 max_age_observed++;
205 } else if (LowerCaseEqualsASCII(tokenizer.token(), 205 } else if (base::LowerCaseEqualsASCII(tokenizer.token(),
206 "includesubdomains")) { 206 "includesubdomains")) {
207 state = AFTER_INCLUDE_SUBDOMAINS; 207 state = AFTER_INCLUDE_SUBDOMAINS;
208 include_subdomains_observed++; 208 include_subdomains_observed++;
209 include_subdomains_candidate = true; 209 include_subdomains_candidate = true;
210 } else { 210 } else {
211 state = AFTER_UNKNOWN_LABEL; 211 state = AFTER_UNKNOWN_LABEL;
212 } 212 }
213 break; 213 break;
214 214
215 case AFTER_MAX_AGE_LABEL: 215 case AFTER_MAX_AGE_LABEL:
216 if (IsAsciiWhitespace(*tokenizer.token_begin())) 216 if (IsAsciiWhitespace(*tokenizer.token_begin()))
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 std::string source = value; 289 std::string source = value;
290 290
291 while (!source.empty()) { 291 while (!source.empty()) {
292 StringPair semicolon = Split(source, ';'); 292 StringPair semicolon = Split(source, ';');
293 semicolon.first = Strip(semicolon.first); 293 semicolon.first = Strip(semicolon.first);
294 semicolon.second = Strip(semicolon.second); 294 semicolon.second = Strip(semicolon.second);
295 StringPair equals = Split(semicolon.first, '='); 295 StringPair equals = Split(semicolon.first, '=');
296 equals.first = Strip(equals.first); 296 equals.first = Strip(equals.first);
297 equals.second = Strip(equals.second); 297 equals.second = Strip(equals.second);
298 298
299 if (LowerCaseEqualsASCII(equals.first, "max-age")) { 299 if (base::LowerCaseEqualsASCII(equals.first, "max-age")) {
300 if (equals.second.empty() || 300 if (equals.second.empty() ||
301 !MaxAgeToInt(equals.second.begin(), equals.second.end(), 301 !MaxAgeToInt(equals.second.begin(), equals.second.end(),
302 &max_age_candidate)) { 302 &max_age_candidate)) {
303 return false; 303 return false;
304 } 304 }
305 parsed_max_age = true; 305 parsed_max_age = true;
306 } else if (LowerCaseEqualsASCII(equals.first, "pin-sha1")) { 306 } else if (base::LowerCaseEqualsASCII(equals.first, "pin-sha1")) {
307 if (!ParseAndAppendPin(equals.second, HASH_VALUE_SHA1, &pins)) 307 if (!ParseAndAppendPin(equals.second, HASH_VALUE_SHA1, &pins))
308 return false; 308 return false;
309 } else if (LowerCaseEqualsASCII(equals.first, "pin-sha256")) { 309 } else if (base::LowerCaseEqualsASCII(equals.first, "pin-sha256")) {
310 if (!ParseAndAppendPin(equals.second, HASH_VALUE_SHA256, &pins)) 310 if (!ParseAndAppendPin(equals.second, HASH_VALUE_SHA256, &pins))
311 return false; 311 return false;
312 } else if (LowerCaseEqualsASCII(equals.first, "includesubdomains")) { 312 } else if (base::LowerCaseEqualsASCII(equals.first, "includesubdomains")) {
313 include_subdomains_candidate = true; 313 include_subdomains_candidate = true;
314 } else { 314 } else {
315 // Silently ignore unknown directives for forward compatibility. 315 // Silently ignore unknown directives for forward compatibility.
316 } 316 }
317 317
318 source = semicolon.second; 318 source = semicolon.second;
319 } 319 }
320 320
321 if (!parsed_max_age) 321 if (!parsed_max_age)
322 return false; 322 return false;
323 323
324 if (!IsPinListValid(pins, chain_hashes)) 324 if (!IsPinListValid(pins, chain_hashes))
325 return false; 325 return false;
326 326
327 *max_age = base::TimeDelta::FromSeconds(max_age_candidate); 327 *max_age = base::TimeDelta::FromSeconds(max_age_candidate);
328 *include_subdomains = include_subdomains_candidate; 328 *include_subdomains = include_subdomains_candidate;
329 hashes->swap(pins); 329 hashes->swap(pins);
330 330
331 return true; 331 return true;
332 } 332 }
333 333
334 } // namespace net 334 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_response_headers.cc ('k') | net/http/http_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698