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

Side by Side Diff: chrome/common/content_settings_pattern_parser.cc

Issue 8676020: Detect invalid content settings pattern that were not detected yet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move one more check to the Validate method Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/common/content_settings_pattern_parser.h" 5 #include "chrome/common/content_settings_pattern_parser.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/common/url_constants.h" 8 #include "chrome/common/url_constants.h"
9 #include "net/base/net_util.h" 9 #include "net/base/net_util.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 builder->WithSchemeWildcard(); 133 builder->WithSchemeWildcard();
134 } 134 }
135 135
136 if (host_component.IsNonEmpty()) { 136 if (host_component.IsNonEmpty()) {
137 std::string host = pattern_spec.substr(host_component.start, 137 std::string host = pattern_spec.substr(host_component.start,
138 host_component.len); 138 host_component.len);
139 if (host == kHostWildcard) { 139 if (host == kHostWildcard) {
140 builder->WithDomainWildcard(); 140 builder->WithDomainWildcard();
141 } else if (StartsWithASCII(host, kDomainWildcard, true)) { 141 } else if (StartsWithASCII(host, kDomainWildcard, true)) {
142 host = host.substr(kDomainWildcardLength); 142 host = host.substr(kDomainWildcardLength);
143 // If the host still contains a wildcard symbol then it is invalid. 143 // If the host contains a domain wildcard but no domain then it is
Bernhard Bauer 2011/11/24 15:50:32 This would be a pattern that's just "[*.]"? I thin
markusheintz_ 2011/11/24 16:37:51 True. Done
144 if (host.find(kHostWildcard) != std::string::npos) { 144 // invalid.
145 if (host.empty()) {
145 builder->Invalid(); 146 builder->Invalid();
146 return; 147 return;
147 } else { 148 } else {
148 builder->WithDomainWildcard(); 149 builder->WithDomainWildcard();
149 builder->WithHost(host); 150 builder->WithHost(host);
150 } 151 }
151 } else { 152 } else {
152 // If the host contains a wildcard symbol then it is invalid. 153 // If the host contains a wildcard symbol then it is invalid.
153 if (host.find(kHostWildcard) != std::string::npos) { 154 if (host.find(kHostWildcard) != std::string::npos) {
154 builder->Invalid(); 155 builder->Invalid();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 218 }
218 219
219 if (!parts.is_port_wildcard) { 220 if (!parts.is_port_wildcard) {
220 str += std::string(kUrlPortSeparator) + parts.port; 221 str += std::string(kUrlPortSeparator) + parts.port;
221 } 222 }
222 223
223 return str; 224 return str;
224 } 225 }
225 226
226 } // namespace content_settings 227 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698