OLD | NEW |
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 Loading... |
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 builder->WithDomainWildcard(); |
144 if (host.find(kHostWildcard) != std::string::npos) { | 144 builder->WithHost(host); |
145 builder->Invalid(); | |
146 return; | |
147 } else { | |
148 builder->WithDomainWildcard(); | |
149 builder->WithHost(host); | |
150 } | |
151 } else { | 145 } else { |
152 // If the host contains a wildcard symbol then it is invalid. | 146 // If the host contains a wildcard symbol then it is invalid. |
153 if (host.find(kHostWildcard) != std::string::npos) { | 147 if (host.find(kHostWildcard) != std::string::npos) { |
154 builder->Invalid(); | 148 builder->Invalid(); |
155 return; | 149 return; |
156 } | 150 } |
157 builder->WithHost(host); | 151 builder->WithHost(host); |
158 } | 152 } |
159 } | 153 } |
160 | 154 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 211 } |
218 | 212 |
219 if (!parts.is_port_wildcard) { | 213 if (!parts.is_port_wildcard) { |
220 str += std::string(kUrlPortSeparator) + parts.port; | 214 str += std::string(kUrlPortSeparator) + parts.port; |
221 } | 215 } |
222 | 216 |
223 return str; | 217 return str; |
224 } | 218 } |
225 | 219 |
226 } // namespace content_settings | 220 } // namespace content_settings |
OLD | NEW |