Chromium Code Reviews| 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); |