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

Side by Side Diff: net/base/net_util.cc

Issue 7222019: Allow hyphens at the beginning of domain components, except for the last domain component. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 6 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
« no previous file with comments | « net/base/net_util.h ('k') | net/base/net_util_unittest.cc » ('j') | 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/base/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include <unicode/regex.h> 7 #include <unicode/regex.h>
8 #include <unicode/ucnv.h> 8 #include <unicode/ucnv.h>
9 #include <unicode/uidna.h> 9 #include <unicode/uidna.h>
10 #include <unicode/ulocdata.h> 10 #include <unicode/ulocdata.h>
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 return false; 1174 return false;
1175 1175
1176 bool in_component = false; 1176 bool in_component = false;
1177 bool most_recent_component_started_alpha = false; 1177 bool most_recent_component_started_alpha = false;
1178 bool last_char_was_hyphen_or_underscore = false; 1178 bool last_char_was_hyphen_or_underscore = false;
1179 1179
1180 for (std::string::const_iterator i(host.begin()); i != host.end(); ++i) { 1180 for (std::string::const_iterator i(host.begin()); i != host.end(); ++i) {
1181 const char c = *i; 1181 const char c = *i;
1182 if (!in_component) { 1182 if (!in_component) {
1183 most_recent_component_started_alpha = IsHostCharAlpha(c); 1183 most_recent_component_started_alpha = IsHostCharAlpha(c);
1184 if (!most_recent_component_started_alpha && !IsHostCharDigit(c)) 1184 if (!most_recent_component_started_alpha && !IsHostCharDigit(c) &&
1185 (c != '-'))
1185 return false; 1186 return false;
1186 in_component = true; 1187 in_component = true;
1187 } else { 1188 } else {
1188 if (c == '.') { 1189 if (c == '.') {
1189 if (last_char_was_hyphen_or_underscore) 1190 if (last_char_was_hyphen_or_underscore)
1190 return false; 1191 return false;
1191 in_component = false; 1192 in_component = false;
1192 } else if (IsHostCharAlpha(c) || IsHostCharDigit(c)) { 1193 } else if (IsHostCharAlpha(c) || IsHostCharDigit(c)) {
1193 last_char_was_hyphen_or_underscore = false; 1194 last_char_was_hyphen_or_underscore = false;
1194 } else if ((c == '-') || (c == '_')) { 1195 } else if ((c == '-') || (c == '_')) {
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
2241 2242
2242 NetworkInterface::NetworkInterface(const std::string& name, 2243 NetworkInterface::NetworkInterface(const std::string& name,
2243 const IPAddressNumber& address) 2244 const IPAddressNumber& address)
2244 : name(name), address(address) { 2245 : name(name), address(address) {
2245 } 2246 }
2246 2247
2247 NetworkInterface::~NetworkInterface() { 2248 NetworkInterface::~NetworkInterface() {
2248 } 2249 }
2249 2250
2250 } // namespace net 2251 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_util.h ('k') | net/base/net_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698