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

Side by Side Diff: chrome/browser/autocomplete/autocomplete.cc

Issue 339017: Loosen RFC 1738 compliance check to allow underscores where we already allowe... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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 | « no previous file | chrome/browser/autocomplete/autocomplete_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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/autocomplete/autocomplete.h" 5 #include "chrome/browser/autocomplete/autocomplete.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 return QUERY; 168 return QUERY;
169 169
170 // Likewise, the RCDS can reject certain obviously-invalid hosts. (We also 170 // Likewise, the RCDS can reject certain obviously-invalid hosts. (We also
171 // use the registry length later below.) 171 // use the registry length later below.)
172 const std::wstring host(text.substr(parts->host.begin, parts->host.len)); 172 const std::wstring host(text.substr(parts->host.begin, parts->host.len));
173 const size_t registry_length = 173 const size_t registry_length =
174 net::RegistryControlledDomainService::GetRegistryLength(host, false); 174 net::RegistryControlledDomainService::GetRegistryLength(host, false);
175 if (registry_length == std::wstring::npos) 175 if (registry_length == std::wstring::npos)
176 return QUERY; // Could be a broken IP address, etc. 176 return QUERY; // Could be a broken IP address, etc.
177 177
178 // See if the hostname is valid per RFC 1738. While IE and GURL allow 178 // See if the hostname is valid. While IE and GURL allow hostnames to contain
179 // hostnames to contain many other characters (perhaps for weird intranet 179 // many other characters (perhaps for weird intranet machines), it's extremely
180 // machines), it's extremely unlikely that a user would be trying to type 180 // unlikely that a user would be trying to type those in for anything other
181 // those in for anything other than a search query. 181 // than a search query.
182 url_canon::CanonHostInfo host_info; 182 url_canon::CanonHostInfo host_info;
183 const std::string canonicalized_host(net::CanonicalizeHost(host, &host_info)); 183 const std::string canonicalized_host(net::CanonicalizeHost(host, &host_info));
184 if ((host_info.family == url_canon::CanonHostInfo::NEUTRAL) && 184 if ((host_info.family == url_canon::CanonHostInfo::NEUTRAL) &&
185 !net::IsCanonicalizedHostRFC1738Compliant(canonicalized_host)) 185 !net::IsCanonicalizedHostCompliant(canonicalized_host))
186 return QUERY; 186 return QUERY;
187 187
188 // Presence of a port means this is likely a URL, if the port is really a port 188 // Presence of a port means this is likely a URL, if the port is really a port
189 // number. If it's just garbage after a colon, this is a query. 189 // number. If it's just garbage after a colon, this is a query.
190 if (parts->port.is_nonempty()) { 190 if (parts->port.is_nonempty()) {
191 int port; 191 int port;
192 return (StringToInt(WideToUTF16( 192 return (StringToInt(WideToUTF16(
193 text.substr(parts->port.begin, parts->port.len)), &port) && 193 text.substr(parts->port.begin, parts->port.len)), &port) &&
194 (port >= 0) && (port <= 65535)) ? URL : QUERY; 194 (port >= 0) && (port <= 65535)) ? URL : QUERY;
195 } 195 }
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 void AutocompleteController::CheckIfDone() { 941 void AutocompleteController::CheckIfDone() {
942 for (ACProviders::const_iterator i(providers_.begin()); i != providers_.end(); 942 for (ACProviders::const_iterator i(providers_.begin()); i != providers_.end();
943 ++i) { 943 ++i) {
944 if (!(*i)->done()) { 944 if (!(*i)->done()) {
945 done_ = false; 945 done_ = false;
946 return; 946 return;
947 } 947 }
948 } 948 }
949 done_ = true; 949 done_ = true;
950 } 950 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/autocomplete_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698