(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
1 changed files with 21 additions and 16 deletions

View File

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