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

Side by Side Diff: extensions/common/csp_validator.cc

Issue 2451353002: Reduce buggy usage of the registry controlled domain service. (Closed)
Patch Set: Fix Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "extensions/common/csp_validator.h" 5 #include "extensions/common/csp_validator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 if (!is_wildcard_subdomain || !should_check_rcd) 112 if (!is_wildcard_subdomain || !should_check_rcd)
113 return true; 113 return true;
114 114
115 // Allow *.googleapis.com to be whitelisted for backwards-compatibility. 115 // Allow *.googleapis.com to be whitelisted for backwards-compatibility.
116 // (crbug.com/409952) 116 // (crbug.com/409952)
117 if (host == "googleapis.com") 117 if (host == "googleapis.com")
118 return true; 118 return true;
119 119
120 // Wildcards on subdomains of a TLD are not allowed. 120 // Wildcards on subdomains of a TLD are not allowed.
121 size_t registry_length = net::registry_controlled_domains::GetRegistryLength( 121 return net::registry_controlled_domains::HostHasRegistryControlledDomain(
122 host, 122 host, net::registry_controlled_domains::INCLUDE_UNKNOWN_REGISTRIES,
123 net::registry_controlled_domains::INCLUDE_UNKNOWN_REGISTRIES,
124 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 123 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
125 return registry_length != 0;
126 } 124 }
127 125
128 // Checks whether the source is a syntactically valid hash. 126 // Checks whether the source is a syntactically valid hash.
129 bool IsHashSource(const std::string& source) { 127 bool IsHashSource(const std::string& source) {
130 size_t hash_end = source.length() - 1; 128 size_t hash_end = source.length() - 1;
131 if (source.empty() || source[hash_end] != '\'') { 129 if (source.empty() || source[hash_end] != '\'') {
132 return false; 130 return false;
133 } 131 }
134 132
135 for (const char* prefix : kHashSourcePrefixes) { 133 for (const char* prefix : kHashSourcePrefixes) {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 367 }
370 } 368 }
371 } 369 }
372 370
373 return seen_sandbox; 371 return seen_sandbox;
374 } 372 }
375 373
376 } // namespace csp_validator 374 } // namespace csp_validator
377 375
378 } // namespace extensions 376 } // namespace extensions
OLDNEW
« no previous file with comments | « content/renderer/webpublicsuffixlist_impl.cc ('k') | extensions/common/manifest_handlers/externally_connectable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698