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

Side by Side Diff: net/base/net_util.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/base/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <unicode/regex.h> 9 #include <unicode/regex.h>
10 #include <unicode/ucnv.h> 10 #include <unicode/ucnv.h>
(...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 // The comma delimiter. 1669 // The comma delimiter.
1670 const std::string::value_type kComma = ','; 1670 const std::string::value_type kComma = ',';
1671 1671
1672 // Overflow is still possible for evil user inputs. 1672 // Overflow is still possible for evil user inputs.
1673 for (size_t i = 0; i <= size; ++i) { 1673 for (size_t i = 0; i <= size; ++i) {
1674 // The string should be composed of only digits and commas. 1674 // The string should be composed of only digits and commas.
1675 if (i != size && !IsAsciiDigit(allowed_ports[i]) && 1675 if (i != size && !IsAsciiDigit(allowed_ports[i]) &&
1676 (allowed_ports[i] != kComma)) 1676 (allowed_ports[i] != kComma))
1677 return; 1677 return;
1678 if (i == size || allowed_ports[i] == kComma) { 1678 if (i == size || allowed_ports[i] == kComma) {
1679 size_t length = i - last; 1679 if (i > last) {
1680 if (length > 0) {
1681 int port; 1680 int port;
1682 base::StringToInt(allowed_ports.substr(last, length), &port); 1681 base::StringToInt(allowed_ports.begin() + last,
1682 allowed_ports.begin() + i,
1683 &port);
1683 ports.insert(port); 1684 ports.insert(port);
1684 } 1685 }
1685 last = i + 1; 1686 last = i + 1;
1686 } 1687 }
1687 } 1688 }
1688 explicitly_allowed_ports = ports; 1689 explicitly_allowed_ports = ports;
1689 } 1690 }
1690 1691
1691 enum IPv6SupportStatus { 1692 enum IPv6SupportStatus {
1692 IPV6_CANNOT_CREATE_SOCKETS, 1693 IPV6_CANNOT_CREATE_SOCKETS,
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 } 1990 }
1990 1991
1991 int GetPortFromAddrinfo(const struct addrinfo* info) { 1992 int GetPortFromAddrinfo(const struct addrinfo* info) {
1992 uint16* port_field = GetPortFieldFromAddrinfo(info); 1993 uint16* port_field = GetPortFieldFromAddrinfo(info);
1993 if (!port_field) 1994 if (!port_field)
1994 return -1; 1995 return -1;
1995 return ntohs(*port_field); 1996 return ntohs(*port_field);
1996 } 1997 }
1997 1998
1998 } // namespace net 1999 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698