OLD | NEW |
---|---|
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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 base::TimeDelta* max_age, | 278 base::TimeDelta* max_age, |
279 bool* include_subdomains, | 279 bool* include_subdomains, |
280 HashValueVector* hashes) { | 280 HashValueVector* hashes) { |
281 bool parsed_max_age = false; | 281 bool parsed_max_age = false; |
282 bool include_subdomains_candidate = false; | 282 bool include_subdomains_candidate = false; |
283 uint32 max_age_candidate = 0; | 283 uint32 max_age_candidate = 0; |
284 HashValueVector pins; | 284 HashValueVector pins; |
285 | 285 |
286 std::string source = value; | 286 std::string source = value; |
287 | 287 |
288 hashes->clear(); | |
Ryan Sleevi
2015/01/13 21:56:40
BUG: You should not clear this unless things parse
davidben
2015/01/13 23:30:47
Nah. AddHPKPHeader only ever calls it on a tempora
| |
288 while (!source.empty()) { | 289 while (!source.empty()) { |
289 StringPair semicolon = Split(source, ';'); | 290 StringPair semicolon = Split(source, ';'); |
290 semicolon.first = Strip(semicolon.first); | 291 semicolon.first = Strip(semicolon.first); |
291 semicolon.second = Strip(semicolon.second); | 292 semicolon.second = Strip(semicolon.second); |
292 StringPair equals = Split(semicolon.first, '='); | 293 StringPair equals = Split(semicolon.first, '='); |
293 equals.first = Strip(equals.first); | 294 equals.first = Strip(equals.first); |
294 equals.second = Strip(equals.second); | 295 equals.second = Strip(equals.second); |
295 | 296 |
296 if (LowerCaseEqualsASCII(equals.first, "max-age")) { | 297 if (LowerCaseEqualsASCII(equals.first, "max-age")) { |
297 if (equals.second.empty() || | 298 if (equals.second.empty() || |
(...skipping 20 matching lines...) Expand all Loading... | |
318 if (!parsed_max_age) | 319 if (!parsed_max_age) |
319 return false; | 320 return false; |
320 | 321 |
321 if (!IsPinListValid(pins, chain_hashes)) | 322 if (!IsPinListValid(pins, chain_hashes)) |
322 return false; | 323 return false; |
323 | 324 |
324 *max_age = base::TimeDelta::FromSeconds(max_age_candidate); | 325 *max_age = base::TimeDelta::FromSeconds(max_age_candidate); |
325 *include_subdomains = include_subdomains_candidate; | 326 *include_subdomains = include_subdomains_candidate; |
326 for (HashValueVector::const_iterator i = pins.begin(); | 327 for (HashValueVector::const_iterator i = pins.begin(); |
327 i != pins.end(); ++i) { | 328 i != pins.end(); ++i) { |
328 bool found = false; | 329 hashes->push_back(*i); |
Ryan Sleevi
2015/01/13 21:56:40
These are both HashValueVectors.
Why don't you ju
davidben
2015/01/13 23:30:47
Yeah, that's better. Done.
| |
329 | |
330 for (HashValueVector::const_iterator j = hashes->begin(); | |
331 j != hashes->end(); ++j) { | |
332 if (j->Equals(*i)) { | |
333 found = true; | |
334 break; | |
335 } | |
336 } | |
337 | |
338 if (!found) | |
339 hashes->push_back(*i); | |
340 } | 330 } |
341 | 331 |
342 return true; | 332 return true; |
343 } | 333 } |
344 | 334 |
345 } // namespace net | 335 } // namespace net |
OLD | NEW |