mirror of
https://github.com/curl/curl.git
synced 2026-07-29 23:28:08 +03:00
curl: return error if etag options are used with multiple URLs
And document it. Add tests 484 and 485 Fixes #15729 Reported-by: Tamir Duberstein Closes #15731
This commit is contained in:
parent
0439499170
commit
a300879b63
7 changed files with 113 additions and 6 deletions
|
|
@ -130,6 +130,7 @@ struct OperationConfig {
|
|||
struct getout *url_get; /* point to the node to fill in URL */
|
||||
struct getout *url_out; /* point to the node to fill in outfile */
|
||||
struct getout *url_ul; /* point to the node to fill in upload */
|
||||
size_t num_urls; /* number of URLs added to the list */
|
||||
#ifndef CURL_DISABLE_IPFS
|
||||
char *ipfs_gateway;
|
||||
#endif /* !CURL_DISABLE_IPFS */
|
||||
|
|
|
|||
|
|
@ -1019,7 +1019,8 @@ const struct LongShort *findlongopt(const char *opt)
|
|||
sizeof(aliases[0]), findarg);
|
||||
}
|
||||
|
||||
static ParameterError parse_url(struct OperationConfig *config,
|
||||
static ParameterError parse_url(struct GlobalConfig *global,
|
||||
struct OperationConfig *config,
|
||||
const char *nextarg)
|
||||
{
|
||||
ParameterError err = PARAM_OK;
|
||||
|
|
@ -1050,6 +1051,11 @@ static ParameterError parse_url(struct OperationConfig *config,
|
|||
/* fill in the URL */
|
||||
err = getstr(&url->url, nextarg, DENY_BLANK);
|
||||
url->flags |= GETOUT_URL;
|
||||
if((++config->num_urls > 1) && (config->etag_save_file ||
|
||||
config->etag_compare_file)) {
|
||||
errorf(global, "The etag options only work on a single URL");
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
|
@ -1911,7 +1917,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
|
|||
config->xattr = toggle;
|
||||
break;
|
||||
case C_URL: /* --url */
|
||||
err = parse_url(config, nextarg);
|
||||
err = parse_url(global, config, nextarg);
|
||||
break;
|
||||
case C_FTP_SSL: /* --ftp-ssl */
|
||||
case C_SSL: /* --ssl */
|
||||
|
|
@ -2549,10 +2555,20 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
|
|||
config->socks5_auth &= ~CURLAUTH_GSSAPI;
|
||||
break;
|
||||
case C_ETAG_SAVE: /* --etag-save */
|
||||
err = getstr(&config->etag_save_file, nextarg, DENY_BLANK);
|
||||
if(config->num_urls > 1) {
|
||||
errorf(global, "The etag options only work on a single URL");
|
||||
err = PARAM_BAD_USE;
|
||||
}
|
||||
else
|
||||
err = getstr(&config->etag_save_file, nextarg, DENY_BLANK);
|
||||
break;
|
||||
case C_ETAG_COMPARE: /* --etag-compare */
|
||||
err = getstr(&config->etag_compare_file, nextarg, DENY_BLANK);
|
||||
if(config->num_urls > 1) {
|
||||
errorf(global, "The etag options only work on a single URL");
|
||||
err = PARAM_BAD_USE;
|
||||
}
|
||||
else
|
||||
err = getstr(&config->etag_compare_file, nextarg, DENY_BLANK);
|
||||
break;
|
||||
case C_CURVES: /* --curves */
|
||||
err = getstr(&config->ssl_ec_curves, nextarg, DENY_BLANK);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue