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

Unified Diff: net/base/ip_address.cc

Issue 1829873002: Add base/parse_number.h to generalize number parsing done in //net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more tests Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/host_port_pair_unittest.cc ('k') | net/base/parse_number.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/ip_address.cc
diff --git a/net/base/ip_address.cc b/net/base/ip_address.cc
index 26c8cc56439323886cc0883c8d926b23f9151661..b805317eef3675ea0dafe63353bef32bb199c8aa 100644
--- a/net/base/ip_address.cc
+++ b/net/base/ip_address.cc
@@ -4,10 +4,10 @@
#include "net/base/ip_address.h"
-#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_split.h"
#include "net/base/ip_address_number.h"
+#include "net/base/parse_number.h"
#include "url/gurl.h"
#include "url/url_canon_ip.h"
@@ -179,15 +179,9 @@ bool ParseCIDRBlock(const std::string& cidr_literal,
if (!ip_address->AssignFromIPLiteral(parts[0]))
return false;
- // TODO(martijnc): Find a more general solution for the overly permissive
- // base::StringToInt() parsing. https://crbug.com/596523.
- const base::StringPiece& prefix_length = parts[1];
- if (prefix_length.starts_with("+"))
- return false;
-
// Parse the prefix length.
int number_of_bits = -1;
- if (!base::StringToInt(prefix_length, &number_of_bits))
+ if (!ParseNonNegativeDecimalInt(parts[1], &number_of_bits))
return false;
// Make sure the prefix length is in a valid range.
« no previous file with comments | « net/base/host_port_pair_unittest.cc ('k') | net/base/parse_number.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698