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

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

Issue 1828103002: Extend net/base/parse_number.h for parsing of negative numbers, and determining if there was overflo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@proxy_num
Patch Set: fix comments Created 4 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
« no previous file with comments | « net/cert/x509_cert_types.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/proxy/proxy_bypass_rules.h" 5 #include "net/proxy/proxy_bypass_rules.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/strings/pattern.h" 8 #include "base/strings/pattern.h"
9 #include "base/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
10 #include "base/strings/string_tokenizer.h" 10 #include "base/strings/string_tokenizer.h"
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 // Canonicalize the IP literal before adding it as a string pattern. 312 // Canonicalize the IP literal before adding it as a string pattern.
313 GURL tmp_url("http://" + bracketed_host); 313 GURL tmp_url("http://" + bracketed_host);
314 return AddRuleForHostname(scheme, tmp_url.host(), port); 314 return AddRuleForHostname(scheme, tmp_url.host(), port);
315 } 315 }
316 } 316 }
317 317
318 // Otherwise assume we have <hostname-pattern>[:port]. 318 // Otherwise assume we have <hostname-pattern>[:port].
319 std::string::size_type pos_colon = raw.rfind(':'); 319 std::string::size_type pos_colon = raw.rfind(':');
320 port = -1; 320 port = -1;
321 if (pos_colon != std::string::npos) { 321 if (pos_colon != std::string::npos) {
322 if (!ParseNonNegativeDecimalInt( 322 if (!ParseInt32(base::StringPiece(raw.begin() + pos_colon + 1, raw.end()),
323 base::StringPiece(raw.begin() + pos_colon + 1, raw.end()), &port) || 323 ParseIntFormat::NON_NEGATIVE, &port) ||
324 port > 0xFFFF) { 324 port > 0xFFFF) {
325 return false; // Port was invalid. 325 return false; // Port was invalid.
326 } 326 }
327 raw = raw.substr(0, pos_colon); 327 raw = raw.substr(0, pos_colon);
328 } 328 }
329 329
330 // Special-case hostnames that begin with a period. 330 // Special-case hostnames that begin with a period.
331 // For example, we remap ".google.com" --> "*.google.com". 331 // For example, we remap ".google.com" --> "*.google.com".
332 if (base::StartsWith(raw, ".", base::CompareCase::SENSITIVE)) 332 if (base::StartsWith(raw, ".", base::CompareCase::SENSITIVE))
333 raw = "*" + raw; 333 raw = "*" + raw;
334 334
335 // If suffix matching was asked for, make sure the pattern starts with a 335 // If suffix matching was asked for, make sure the pattern starts with a
336 // wildcard. 336 // wildcard.
337 if (use_hostname_suffix_matching && 337 if (use_hostname_suffix_matching &&
338 !base::StartsWith(raw, "*", base::CompareCase::SENSITIVE)) 338 !base::StartsWith(raw, "*", base::CompareCase::SENSITIVE))
339 raw = "*" + raw; 339 raw = "*" + raw;
340 340
341 return AddRuleForHostname(scheme, raw, port); 341 return AddRuleForHostname(scheme, raw, port);
342 } 342 }
343 343
344 bool ProxyBypassRules::AddRuleFromStringInternalWithLogging( 344 bool ProxyBypassRules::AddRuleFromStringInternalWithLogging(
345 const std::string& raw, 345 const std::string& raw,
346 bool use_hostname_suffix_matching) { 346 bool use_hostname_suffix_matching) {
347 return AddRuleFromStringInternal(raw, use_hostname_suffix_matching); 347 return AddRuleFromStringInternal(raw, use_hostname_suffix_matching);
348 } 348 }
349 349
350 } // namespace net 350 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/x509_cert_types.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698