Fix --accept-regex/i--reject-regex for FTP

* src/ftp.c (ftp_retrieve_glob): Call accept_url() with the full URL

Reported-by: Frans de Boer <frans@fransdb.nl>
This commit is contained in:
Tim Rühsen 2020-12-28 19:33:20 +01:00 committed by Darshit Shah
parent 2e4504c553
commit 5b7d068a4b

View File

@ -2660,11 +2660,30 @@ ftp_retrieve_glob (struct url *u, struct url *original_url,
continue;
}
if (!accept_url (f->name))
if (opt.acceptregex || opt.rejectregex)
{
logprintf (LOG_VERBOSE, _("%s is excluded/not-included through regex.\n"), f->name);
f = delelement (&f, &start);
continue;
// accept_url() takes the full URL.
char buf[1024];
char *url = buf;
if ((unsigned) snprintf(buf, sizeof(buf), "%s%s%s",
u->url, f->name, f->type == FT_DIRECTORY ? "/" : "")
>= sizeof(buf))
{
url = aprintf("%s%s%s", u->url, f->name, f->type == FT_DIRECTORY ? "/" : "");
}
if (!accept_url (url))
{
logprintf (LOG_VERBOSE, _ ("%s is excluded/not-included through regex.\n"), url);
f = delelement (&f, &start);
if (url != buf)
xfree(url);
continue;
}
if (url != buf)
xfree(url);
}
/* Now weed out the files that do not match our globbing pattern.