mirror of
https://github.com/curl/curl.git
synced 2026-05-21 02:36:23 +03:00
ftp: fix prequotes for a directory in URL
Allow prequotes to be sent after curl has changed the working directory, just before the listing command if the URL is a directory. FTP state machine is updated with the new FTP_LIST_PREQUOTE state and FTP_RETR_LIST_TYPE type. Test 754 verifies Fixes #8602 Closes #17616
This commit is contained in:
parent
149d436457
commit
fdf50d64b8
4 changed files with 96 additions and 4 deletions
32
lib/ftp.c
32
lib/ftp.c
|
|
@ -114,12 +114,14 @@ static const char * const ftp_state_names[]={
|
|||
"QUOTE",
|
||||
"RETR_PREQUOTE",
|
||||
"STOR_PREQUOTE",
|
||||
"LIST_PREQUOTE",
|
||||
"POSTQUOTE",
|
||||
"CWD",
|
||||
"MKD",
|
||||
"MDTM",
|
||||
"TYPE",
|
||||
"LIST_TYPE",
|
||||
"RETR_LIST_TYPE",
|
||||
"RETR_TYPE",
|
||||
"STOR_TYPE",
|
||||
"SIZE",
|
||||
|
|
@ -1459,6 +1461,14 @@ static CURLcode ftp_state_list(struct Curl_easy *data,
|
|||
return result;
|
||||
}
|
||||
|
||||
static CURLcode ftp_state_list_prequote(struct Curl_easy *data,
|
||||
struct ftp_conn *ftpc,
|
||||
struct FTP *ftp)
|
||||
{
|
||||
/* We have sent the TYPE, now we must send the list of prequote strings */
|
||||
return ftp_state_quote(data, ftpc, ftp, TRUE, FTP_LIST_PREQUOTE);
|
||||
}
|
||||
|
||||
static CURLcode ftp_state_retr_prequote(struct Curl_easy *data,
|
||||
struct ftp_conn *ftpc,
|
||||
struct FTP *ftp)
|
||||
|
|
@ -1647,6 +1657,7 @@ static CURLcode ftp_state_quote(struct Curl_easy *data,
|
|||
break;
|
||||
case FTP_RETR_PREQUOTE:
|
||||
case FTP_STOR_PREQUOTE:
|
||||
case FTP_LIST_PREQUOTE:
|
||||
item = data->set.prequote;
|
||||
break;
|
||||
case FTP_POSTQUOTE:
|
||||
|
|
@ -1736,6 +1747,10 @@ static CURLcode ftp_state_quote(struct Curl_easy *data,
|
|||
break;
|
||||
case FTP_POSTQUOTE:
|
||||
break;
|
||||
case FTP_LIST_PREQUOTE:
|
||||
ftp_state(data, ftpc, FTP_LIST_TYPE);
|
||||
result = ftp_state_list(data, ftpc, ftp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2209,6 +2224,8 @@ static CURLcode ftp_state_type_resp(struct Curl_easy *data,
|
|||
result = ftp_state_retr_prequote(data, ftpc, ftp);
|
||||
else if(instate == FTP_STOR_TYPE)
|
||||
result = ftp_state_stor_prequote(data, ftpc, ftp);
|
||||
else if(instate == FTP_RETR_LIST_TYPE)
|
||||
result = ftp_state_list_prequote(data, ftpc, ftp);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -3013,6 +3030,7 @@ static CURLcode ftp_pp_statemachine(struct Curl_easy *data,
|
|||
case FTP_POSTQUOTE:
|
||||
case FTP_RETR_PREQUOTE:
|
||||
case FTP_STOR_PREQUOTE:
|
||||
case FTP_LIST_PREQUOTE:
|
||||
if((ftpcode >= 400) && !ftpc->count2) {
|
||||
/* failure response code, and not allowed to fail */
|
||||
failf(data, "QUOT command failed with %03d", ftpcode);
|
||||
|
|
@ -3082,6 +3100,7 @@ static CURLcode ftp_pp_statemachine(struct Curl_easy *data,
|
|||
case FTP_LIST_TYPE:
|
||||
case FTP_RETR_TYPE:
|
||||
case FTP_STOR_TYPE:
|
||||
case FTP_RETR_LIST_TYPE:
|
||||
result = ftp_state_type_resp(data, ftpc, ftp, ftpcode, ftpc->state);
|
||||
break;
|
||||
|
||||
|
|
@ -3686,7 +3705,8 @@ static CURLcode ftp_do_more(struct Curl_easy *data, int *completep)
|
|||
|
||||
if(result)
|
||||
;
|
||||
else if(data->state.list_only || !ftpc->file) {
|
||||
else if((data->state.list_only || !ftpc->file) &&
|
||||
!(data->set.prequote)) {
|
||||
/* The specified path ends with a slash, and therefore we think this
|
||||
is a directory that is requested, use LIST. But before that we
|
||||
need to set ASCII transfer mode. */
|
||||
|
|
@ -3700,8 +3720,14 @@ static CURLcode ftp_do_more(struct Curl_easy *data, int *completep)
|
|||
/* otherwise just fall through */
|
||||
}
|
||||
else {
|
||||
result = ftp_nb_type(data, ftpc, ftp, data->state.prefer_ascii,
|
||||
FTP_RETR_TYPE);
|
||||
if(data->set.prequote && !ftpc->file) {
|
||||
result = ftp_nb_type(data, ftpc, ftp, TRUE,
|
||||
FTP_RETR_LIST_TYPE);
|
||||
}
|
||||
else {
|
||||
result = ftp_nb_type(data, ftpc, ftp, data->state.prefer_ascii,
|
||||
FTP_RETR_TYPE);
|
||||
}
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,12 +62,14 @@ enum {
|
|||
FTP_QUOTE, /* waiting for a response to a command sent in a quote list */
|
||||
FTP_RETR_PREQUOTE,
|
||||
FTP_STOR_PREQUOTE,
|
||||
FTP_LIST_PREQUOTE,
|
||||
FTP_POSTQUOTE,
|
||||
FTP_CWD, /* change dir */
|
||||
FTP_MKD, /* if the dir did not exist */
|
||||
FTP_MDTM, /* to figure out the datestamp */
|
||||
FTP_TYPE, /* to set type when doing a head-like request */
|
||||
FTP_LIST_TYPE, /* set type when about to do a dir list */
|
||||
FTP_RETR_LIST_TYPE,
|
||||
FTP_RETR_TYPE, /* set type when about to RETR a file */
|
||||
FTP_STOR_TYPE, /* set type when about to STOR a file */
|
||||
FTP_SIZE, /* get the remote file's size for head-like request */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue