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

Unified Diff: net/http/http_security_headers.cc

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: net/http/http_security_headers.cc
diff --git a/net/http/http_security_headers.cc b/net/http/http_security_headers.cc
index 8d0c1465307f8adb5da5eb61907e2a0b8b2d9da6..aff4a305a2902a9738693fca030dcd5e11703535 100644
--- a/net/http/http_security_headers.cc
+++ b/net/http/http_security_headers.cc
@@ -14,7 +14,7 @@ namespace net {
namespace {
-COMPILE_ASSERT(kMaxHSTSAgeSecs <= kuint32max, kMaxHSTSAgeSecsTooLarge);
+static_assert(kMaxHSTSAgeSecs <= kuint32max, "kMaxHSTSAgeSecs too large");
// MaxAgeToInt converts a string representation of a "whole number" of
// seconds into a uint32. The string may contain an arbitrarily large number,
@@ -118,12 +118,15 @@ StringPair Split(const std::string& source, char delimiter) {
bool ParseAndAppendPin(const std::string& value,
HashValueTag tag,
HashValueVector* hashes) {
- std::string unquoted = HttpUtil::Unquote(value);
- std::string decoded;
+ // Pins are always quoted.
+ if (value.empty() || !HttpUtil::IsQuote(value[0]))
+ return false;
+ std::string unquoted = HttpUtil::Unquote(value);
if (unquoted.empty())
return false;
+ std::string decoded;
if (!base::Base64Decode(unquoted, &decoded))
return false;
@@ -323,21 +326,7 @@ bool ParseHPKPHeader(const std::string& value,
*max_age = base::TimeDelta::FromSeconds(max_age_candidate);
*include_subdomains = include_subdomains_candidate;
- for (HashValueVector::const_iterator i = pins.begin();
- i != pins.end(); ++i) {
- bool found = false;
-
- for (HashValueVector::const_iterator j = hashes->begin();
- j != hashes->end(); ++j) {
- if (j->Equals(*i)) {
- found = true;
- break;
- }
- }
-
- if (!found)
- hashes->push_back(*i);
- }
+ hashes->swap(pins);
return true;
}

Powered by Google App Engine
This is Rietveld 408576698