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

Side by Side Diff: net/proxy/proxy_bypass_rules.cc

Issue 3968001: Update code that previously constructed strings from string iterators only to... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "net/proxy/proxy_bypass_rules.h" 5 #include "net/proxy/proxy_bypass_rules.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/string_tokenizer.h" 8 #include "base/string_tokenizer.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/base/net_util.h" 10 #include "net/base/net_util.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 GURL tmp_url("http://" + host); 257 GURL tmp_url("http://" + host);
258 return AddRuleForHostname(scheme, tmp_url.host(), port); 258 return AddRuleForHostname(scheme, tmp_url.host(), port);
259 } 259 }
260 } 260 }
261 261
262 // Otherwise assume we have <hostname-pattern>[:port]. 262 // Otherwise assume we have <hostname-pattern>[:port].
263 std::string::size_type pos_colon = raw.rfind(':'); 263 std::string::size_type pos_colon = raw.rfind(':');
264 host = raw; 264 host = raw;
265 port = -1; 265 port = -1;
266 if (pos_colon != std::string::npos) { 266 if (pos_colon != std::string::npos) {
267 if (!base::StringToInt(raw.substr(pos_colon + 1), &port) || 267 if (!base::StringToInt(raw.begin() + pos_colon + 1, raw.end(), &port) ||
268 (port < 0 || port > 0xFFFF)) { 268 (port < 0 || port > 0xFFFF)) {
269 return false; // Port was invalid. 269 return false; // Port was invalid.
270 } 270 }
271 raw = raw.substr(0, pos_colon); 271 raw = raw.substr(0, pos_colon);
272 } 272 }
273 273
274 // Special-case hostnames that begin with a period. 274 // Special-case hostnames that begin with a period.
275 // For example, we remap ".google.com" --> "*.google.com". 275 // For example, we remap ".google.com" --> "*.google.com".
276 if (StartsWithASCII(raw, ".", false)) 276 if (StartsWithASCII(raw, ".", false))
277 raw = "*" + raw; 277 raw = "*" + raw;
278 278
279 // If suffix matching was asked for, make sure the pattern starts with a 279 // If suffix matching was asked for, make sure the pattern starts with a
280 // wildcard. 280 // wildcard.
281 if (use_hostname_suffix_matching && !StartsWithASCII(raw, "*", false)) 281 if (use_hostname_suffix_matching && !StartsWithASCII(raw, "*", false))
282 raw = "*" + raw; 282 raw = "*" + raw;
283 283
284 return AddRuleForHostname(scheme, raw, port); 284 return AddRuleForHostname(scheme, raw, port);
285 } 285 }
286 286
287 bool ProxyBypassRules::AddRuleFromStringInternalWithLogging( 287 bool ProxyBypassRules::AddRuleFromStringInternalWithLogging(
288 const std::string& raw, 288 const std::string& raw,
289 bool use_hostname_suffix_matching) { 289 bool use_hostname_suffix_matching) {
290 return AddRuleFromStringInternal(raw, use_hostname_suffix_matching); 290 return AddRuleFromStringInternal(raw, use_hostname_suffix_matching);
291 } 291 }
292 292
293 } // namespace net 293 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698