don't add empty hostnames to _direct_hosts

This commit is contained in:
David Rose 2003-05-29 18:16:45 +00:00
parent 8edea699c2
commit 4c152dad0e

View File

@ -313,8 +313,14 @@ set_direct_host_spec(const string &direct_host_spec) {
for (vector_string::const_iterator hi = hosts.begin(); for (vector_string::const_iterator hi = hosts.begin();
hi != hosts.end(); hi != hosts.end();
++hi) { ++hi) {
const string &spec = (*hi); string spec = trim_blanks(*hi);
add_direct_host(trim_blanks(spec));
// We should be careful to avoid adding any empty hostnames to the
// list. In particular, we will get one empty hostname if the
// direct_host_spec is empty.
if (!spec.empty()) {
add_direct_host(spec);
}
} }
} }
@ -449,7 +455,9 @@ get_proxies_for_url(const URLSpec &url, pvector<URLSpec> &proxies) const {
// First, check if the hostname matches any listed in direct_hosts. // First, check if the hostname matches any listed in direct_hosts.
string hostname = url.get_server(); string hostname = url.get_server();
if (!hostname.empty()) { // skip if hostname is just an empty 'http://' scheme // If the hostname is empty, treat it as a special case: we don't
// match any of the hostnames listed in direct_hosts (even "*").
if (!hostname.empty()) {
DirectHosts::const_iterator si; DirectHosts::const_iterator si;
for (si = _direct_hosts.begin(); si != _direct_hosts.end(); ++si) { for (si = _direct_hosts.begin(); si != _direct_hosts.end(); ++si) {
if ((*si).matches(hostname)) { if ((*si).matches(hostname)) {