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

Unified Diff: net/dns/dns_hosts.h

Issue 415153002: ParseHosts: Allow commas as separators on Mac OS X (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make comma-handling OS-specific Created 6 years, 5 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 | « no previous file | net/dns/dns_hosts.cc » ('j') | net/dns/dns_hosts.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_hosts.h
diff --git a/net/dns/dns_hosts.h b/net/dns/dns_hosts.h
index c2b290907ad78d44a5b762b7f86f86a504e54505..9a6f92327d6f8c310c3b07b1b0bf4c07f575bbc8 100644
--- a/net/dns/dns_hosts.h
+++ b/net/dns/dns_hosts.h
@@ -44,6 +44,17 @@ inline size_t hash_value(const net::DnsHostsKey& key) {
namespace net {
+// There are OS-specific variations in how commas in the hosts file behave.
+enum ParseHostsCommaMode {
+ // Comma is treated as part of a hostname:
+ // "127.0.0.1 foo,bar" parses as "foo,bar" mapping to "127.0.0.1".
+ PARSE_HOSTS_COMMA_IS_TOKEN,
+
+ // Comma is treated as a hostname separator:
+ // "127.0.0.1 foo,bar" parses as "foo" and "bar" both mapping to "127.0.0.1".
+ PARSE_HOSTS_COMMA_IS_WHITESPACE,
+};
+
// Parsed results of a Hosts file.
//
// Although Hosts files map IP address to a list of domain names, for name
@@ -64,6 +75,14 @@ typedef std::map<DnsHostsKey, IPAddressNumber> DnsHosts;
// Parses |contents| (as read from /etc/hosts or equivalent) and stores results
// in |dns_hosts|. Invalid lines are ignored (as in most implementations).
+// Overrides the OS-specific default handling of commas.
+void NET_EXPORT_PRIVATE ParseHostsWithCommaMode(
mmenke 2014/07/24 21:32:30 ParseHostsWithCommaModeForTests?
Deprecated (see juliatuttle) 2014/07/25 19:34:44 Done.
+ const std::string& contents,
+ DnsHosts* dns_hosts,
+ ParseHostsCommaMode comma_mode);
+
+// Parses |contents| (as read from /etc/hosts or equivalent) and stores results
+// in |dns_hosts|. Invalid lines are ignored (as in most implementations).
void NET_EXPORT_PRIVATE ParseHosts(const std::string& contents,
DnsHosts* dns_hosts);
« no previous file with comments | « no previous file | net/dns/dns_hosts.cc » ('j') | net/dns/dns_hosts.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698