(ftpfs_check_proxy): read mc.no_proxy file once only.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2021-12-09 15:00:04 +03:00
parent 76555ad40d
commit ca24b1d136

View File

@ -782,7 +782,6 @@ ftpfs_load_no_proxy_list (void)
static gboolean static gboolean
ftpfs_check_proxy (const char *host) ftpfs_check_proxy (const char *host)
{ {
GSList *npe;
if (ftpfs_proxy_host == NULL || *ftpfs_proxy_host == '\0' || host == NULL || *host == '\0') if (ftpfs_proxy_host == NULL || *ftpfs_proxy_host == '\0' || host == NULL || *host == '\0')
return FALSE; /* sanity check */ return FALSE; /* sanity check */
@ -796,29 +795,35 @@ ftpfs_check_proxy (const char *host)
if (strchr (host, '.') == NULL) if (strchr (host, '.') == NULL)
return FALSE; return FALSE;
ftpfs_load_no_proxy_list (); if (no_proxy == NULL)
for (npe = no_proxy; npe != NULL; npe = g_slist_next (npe))
{ {
const char *domain = (const char *) npe->data; GSList *npe;
if (domain[0] == '.') ftpfs_load_no_proxy_list ();
for (npe = no_proxy; npe != NULL; npe = g_slist_next (npe))
{ {
size_t ld, lh; const char *domain = (const char *) npe->data;
ld = strlen (domain); if (domain[0] == '.')
lh = strlen (host);
while (ld != 0 && lh != 0 && host[lh - 1] == domain[ld - 1])
{ {
ld--; size_t ld, lh;
lh--;
}
if (ld == 0) ld = strlen (domain);
lh = strlen (host);
while (ld != 0 && lh != 0 && host[lh - 1] == domain[ld - 1])
{
ld--;
lh--;
}
if (ld == 0)
return FALSE;
}
else if (g_ascii_strcasecmp (host, domain) == 0)
return FALSE; return FALSE;
} }
else if (g_ascii_strcasecmp (host, domain) == 0)
return FALSE;
} }
return TRUE; return TRUE;