>From 6e4497efd0d5689a8cc0467c30e185ce208c4437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Fri, 11 Sep 2015 10:15:45 +0200 Subject: [PATCH 2/3] Some missing FTPS pieces --- src/http.c | 3 +++ src/main.c | 4 ++-- src/metalink.h | 2 +- src/recur.c | 15 ++++++++------- src/retr.c | 9 ++++++--- src/url.c | 4 ++-- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/http.c b/src/http.c index 67085a0..4c1052d 100644 --- a/src/http.c +++ b/src/http.c @@ -2742,6 +2742,9 @@ metalink_from_http (const struct response *resp, const struct http_stat *hs, case SCHEME_HTTPS: mres.type = xstrdup ("https"); break; + case SCHEME_FTPS: + mres.type = xstrdup ("ftps"); + break; #endif case SCHEME_FTP: mres.type = xstrdup ("ftp"); diff --git a/src/main.c b/src/main.c index 728084b..4ab9ad9 100644 --- a/src/main.c +++ b/src/main.c @@ -1830,12 +1830,12 @@ outputting to a regular file.\n")); else { if ((opt.recursive || opt.page_requisites) - && (url_scheme (*t) != SCHEME_FTP || url_uses_proxy (url_parsed))) + && ((url_scheme (*t) != SCHEME_FTP && url_scheme (*t) != SCHEME_FTPS) || url_uses_proxy (url_parsed))) { int old_follow_ftp = opt.follow_ftp; /* Turn opt.follow_ftp on in case of recursive FTP retrieval */ - if (url_scheme (*t) == SCHEME_FTP) + if (url_scheme (*t) == SCHEME_FTP || url_scheme (*t) == SCHEME_FTPS) opt.follow_ftp = 1; retrieve_tree (url_parsed, NULL); diff --git a/src/metalink.h b/src/metalink.h index ec91b07..e98c210 100644 --- a/src/metalink.h +++ b/src/metalink.h @@ -34,7 +34,7 @@ as that of the covered work. */ #ifdef HAVE_SSL # define RES_TYPE_SUPPORTED(x)\ - ((!x) || !strcmp (x, "ftp") || !strcmp (x, "http") || !strcmp (x, "https")) + ((!x) || !strcmp (x, "http") || !strcmp (x, "https") || !strcmp (x, "ftp") || !strcmp (x, "ftps")) #else # define RES_TYPE_SUPPORTED(x)\ ((!x) || !strcmp (x, "ftp") || !strcmp (x, "http")) diff --git a/src/recur.c b/src/recur.c index ce55362..25cdbb7 100644 --- a/src/recur.c +++ b/src/recur.c @@ -610,7 +610,7 @@ download_child (const struct urlpos *upos, struct url *parent, int depth, u_scheme_like_http = schemes_are_similar_p (u->scheme, SCHEME_HTTP); /* 1. Schemes other than HTTP are normally not recursed into. */ - if (!u_scheme_like_http && !(u->scheme == SCHEME_FTP && opt.follow_ftp)) + if (!u_scheme_like_http && !((u->scheme == SCHEME_FTP || u->scheme == SCHEME_FTPS) && opt.follow_ftp)) { DEBUGP (("Not following non-HTTP schemes.\n")); reason = WG_RR_NONHTTP; @@ -832,12 +832,13 @@ write_reject_log_url (FILE *fp, const struct url *url) switch (url->scheme) { - case SCHEME_HTTP: scheme_str = "SCHEME_HTTP"; break; - #ifdef HAVE_SSL - case SCHEME_HTTPS: scheme_str = "SCHEME_HTTPS"; break; - #endif - case SCHEME_FTP: scheme_str = "SCHEME_FTP"; break; - default: scheme_str = "SCHEME_INVALID"; break; + case SCHEME_HTTP: scheme_str = "SCHEME_HTTP"; break; +#ifdef HAVE_SSL + case SCHEME_HTTPS: scheme_str = "SCHEME_HTTPS"; break; + case SCHEME_FTPS: scheme_str = "SCHEME_FTPS"; break; +#endif + case SCHEME_FTP: scheme_str = "SCHEME_FTP"; break; + default: scheme_str = "SCHEME_INVALID"; break; } fprintf (fp, "%s\t%s\t%s\t%i\t%s\t%s\t%s\t%s", diff --git a/src/retr.c b/src/retr.c index 28d1b35..318b09c 100644 --- a/src/retr.c +++ b/src/retr.c @@ -837,7 +837,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file, FTP. In these cases we must decide whether the text is HTML according to the suffix. The HTML suffixes are `.html', `.htm' and a few others, case-insensitive. */ - if (redirection_count && local_file && u->scheme == SCHEME_FTP) + if (redirection_count && local_file && (u->scheme == SCHEME_FTP || u->scheme == SCHEME_FTPS)) { if (has_html_suffix_p (local_file)) *dt |= TEXTHTML; @@ -1099,12 +1099,12 @@ retrieve_from_file (const char *file, bool html, int *count) proxy = getproxy (cur_url->url); if ((opt.recursive || opt.page_requisites) - && (cur_url->url->scheme != SCHEME_FTP || proxy)) + && ((cur_url->url->scheme != SCHEME_FTP && cur_url->url->scheme != SCHEME_FTPS) || proxy)) { int old_follow_ftp = opt.follow_ftp; /* Turn opt.follow_ftp on in case of recursive FTP retrieval */ - if (cur_url->url->scheme == SCHEME_FTP) + if (cur_url->url->scheme == SCHEME_FTP || cur_url->url->scheme == SCHEME_FTPS) opt.follow_ftp = 1; status = retrieve_tree (parsed_url ? parsed_url : cur_url->url, @@ -1285,6 +1285,9 @@ getproxy (struct url *u) case SCHEME_HTTPS: proxy = opt.https_proxy ? opt.https_proxy : getenv ("https_proxy"); break; + case SCHEME_FTPS: + proxy = opt.ftp_proxy ? opt.ftp_proxy : getenv ("ftps_proxy"); + break; #endif case SCHEME_FTP: proxy = opt.ftp_proxy ? opt.ftp_proxy : getenv ("ftp_proxy"); diff --git a/src/url.c b/src/url.c index b81ebc5..56079cd 100644 --- a/src/url.c +++ b/src/url.c @@ -1779,7 +1779,7 @@ path_simplify (enum url_scheme scheme, char *path) else if (h[0] == '.' && h[1] == '.' && (h[2] == '/' || h[2] == '\0')) { /* Handle "../" by retreating the tortoise by one path - element -- but not past beggining. */ + element -- but not past beginning. */ if (t > beg) { /* Move backwards until T hits the beginning of the @@ -1787,7 +1787,7 @@ path_simplify (enum url_scheme scheme, char *path) for (--t; t > beg && t[-1] != '/'; t--) ; } - else if (scheme == SCHEME_FTP) + else if (scheme == SCHEME_FTP || scheme == SCHEME_FTPS) { /* If we're at the beginning, copy the "../" literally and move the beginning so a later ".." doesn't remove -- 2.5.1