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

Unified Diff: net/dns/dns_transaction.cc

Issue 938093003: Always treat .localhost as loopback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rsleevi's comments Created 5 years, 10 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
Index: net/dns/dns_transaction.cc
diff --git a/net/dns/dns_transaction.cc b/net/dns/dns_transaction.cc
index beb2197dd55b7bc50d39c71cb70d46c29bfd2a77..73a2c40e4b41864f4ef7c43ab064f9708fbb2e4f 100644
--- a/net/dns/dns_transaction.cc
+++ b/net/dns/dns_transaction.cc
@@ -28,6 +28,7 @@
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/base/net_log.h"
+#include "net/base/net_util.h"
#include "net/dns/dns_protocol.h"
#include "net/dns/dns_query.h"
#include "net/dns/dns_response.h"
@@ -616,12 +617,16 @@ class DnsTransactionImpl : public DnsTransaction,
// Prepares |qnames_| according to the DnsConfig.
int PrepareSearch() {
const DnsConfig& config = session_->config();
+ // Redirect .localhost queries to localhost to make sure that they are
Deprecated (see juliatuttle) 2015/02/24 16:39:23 Nit: "to localhost.", since you're including the t
estark 2015/02/26 07:58:53 fixed in the place where this comment has been rel
+ // never sent out on the network, per RFC 6761.
+ const std::string hostname =
+ (IsLocalhostTLD(hostname_) ? "localhost." : hostname_);
std::string labeled_hostname;
- if (!DNSDomainFromDot(hostname_, &labeled_hostname))
+ if (!DNSDomainFromDot(hostname, &labeled_hostname))
return ERR_INVALID_ARGUMENT;
- if (hostname_[hostname_.size() - 1] == '.') {
+ if (hostname[hostname.size() - 1] == '.') {
// It's a fully-qualified name, no suffix search.
qnames_.push_back(labeled_hostname);
return OK;
@@ -645,7 +650,7 @@ class DnsTransactionImpl : public DnsTransaction,
std::string qname;
for (size_t i = 0; i < config.search.size(); ++i) {
// Ignore invalid (too long) combinations.
- if (!DNSDomainFromDot(hostname_ + "." + config.search[i], &qname))
+ if (!DNSDomainFromDot(hostname + "." + config.search[i], &qname))
continue;
if (qname.size() == labeled_hostname.size()) {
if (had_hostname)

Powered by Google App Engine
This is Rietveld 408576698