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

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

Issue 13251012: Fix b180514: Some exception entries cannot be deleted from a setting panel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Forbid multiple ending dots. Created 7 years, 8 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
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 "chrome/common/content_settings_pattern.h" 5 #include "chrome/common/content_settings_pattern.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 if (parts->scheme == std::string(chrome::kFileScheme) && 168 if (parts->scheme == std::string(chrome::kFileScheme) &&
169 !parts->is_path_wildcard) { 169 !parts->is_path_wildcard) {
170 GURL url(std::string(chrome::kFileScheme) + 170 GURL url(std::string(chrome::kFileScheme) +
171 std::string(content::kStandardSchemeSeparator) + parts->path); 171 std::string(content::kStandardSchemeSeparator) + parts->path);
172 parts->path = url.path(); 172 parts->path = url.path();
173 } 173 }
174 174
175 // Canonicalize the host part. 175 // Canonicalize the host part.
176 const std::string host(parts->host); 176 const std::string host(parts->host);
177 if (host.size() >= 2 &&
178 host[host.size() - 1] == '.' &&
markusheintz_ 2013/04/02 19:16:46 What about a..a? Please move this logic to the ch
yhirano 2013/04/02 19:54:54 Done.
179 host[host.size() - 2] == '.') {
180 // There are multiple ending dots.
181 return false;
182 }
183
177 url_canon::CanonHostInfo host_info; 184 url_canon::CanonHostInfo host_info;
178 std::string canonicalized_host(net::CanonicalizeHost(host, &host_info)); 185 std::string canonicalized_host(net::CanonicalizeHost(host, &host_info));
179 if (host_info.IsIPAddress() && parts->has_domain_wildcard) 186 if (host_info.IsIPAddress() && parts->has_domain_wildcard)
180 return false; 187 return false;
181 canonicalized_host = net::TrimEndingDot(canonicalized_host); 188 canonicalized_host = net::TrimEndingDot(canonicalized_host);
182 189
183 parts->host = ""; 190 parts->host = "";
184 if ((host.find('*') == std::string::npos) && 191 if ((host.find('*') == std::string::npos) &&
185 !canonicalized_host.empty()) { 192 !canonicalized_host.empty()) {
186 // Valid host. 193 // Valid host.
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 if (!parts.is_port_wildcard && other_parts.is_port_wildcard) 667 if (!parts.is_port_wildcard && other_parts.is_port_wildcard)
661 return ContentSettingsPattern::PREDECESSOR; 668 return ContentSettingsPattern::PREDECESSOR;
662 669
663 int result = parts.port.compare(other_parts.port); 670 int result = parts.port.compare(other_parts.port);
664 if (result == 0) 671 if (result == 0)
665 return ContentSettingsPattern::IDENTITY; 672 return ContentSettingsPattern::IDENTITY;
666 if (result > 0) 673 if (result > 0)
667 return ContentSettingsPattern::DISJOINT_ORDER_PRE; 674 return ContentSettingsPattern::DISJOINT_ORDER_PRE;
668 return ContentSettingsPattern::DISJOINT_ORDER_POST; 675 return ContentSettingsPattern::DISJOINT_ORDER_POST;
669 } 676 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/content_settings_pattern_unittest.cc » ('j') | chrome/common/content_settings_pattern_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698