mirror of https://github.com/moparisthebest/curl
curl: report error for "--no-" on non-boolean options
Reported-by: Olen Andoni Fixes #3906 Closes #3907
This commit is contained in:
parent
0da8441298
commit
31b77c1877
|
@ -515,11 +515,13 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
|
||||||
const char *word = ('-' == flag[0]) ? flag + 2 : flag;
|
const char *word = ('-' == flag[0]) ? flag + 2 : flag;
|
||||||
size_t fnam = strlen(word);
|
size_t fnam = strlen(word);
|
||||||
int numhits = 0;
|
int numhits = 0;
|
||||||
|
bool noflagged = FALSE;
|
||||||
|
|
||||||
if(!strncmp(word, "no-", 3)) {
|
if(!strncmp(word, "no-", 3)) {
|
||||||
/* disable this option but ignore the "no-" part when looking for it */
|
/* disable this option but ignore the "no-" part when looking for it */
|
||||||
word += 3;
|
word += 3;
|
||||||
toggle = FALSE;
|
toggle = FALSE;
|
||||||
|
noflagged = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) {
|
for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) {
|
||||||
|
@ -543,6 +545,9 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
|
||||||
if(hit < 0) {
|
if(hit < 0) {
|
||||||
return PARAM_OPTION_UNKNOWN;
|
return PARAM_OPTION_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
if(noflagged && (aliases[hit].desc != ARG_BOOL))
|
||||||
|
/* --no- prefixed an option that isn't boolean! */
|
||||||
|
return PARAM_NO_NOT_BOOLEAN;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
flag++; /* prefixed with one dash, pass it */
|
flag++; /* prefixed with one dash, pass it */
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
|
@ -42,6 +42,7 @@ typedef enum {
|
||||||
PARAM_NEXT_OPERATION,
|
PARAM_NEXT_OPERATION,
|
||||||
PARAM_NO_PREFIX,
|
PARAM_NO_PREFIX,
|
||||||
PARAM_NUMBER_TOO_LARGE,
|
PARAM_NUMBER_TOO_LARGE,
|
||||||
|
PARAM_NO_NOT_BOOLEAN,
|
||||||
PARAM_LAST
|
PARAM_LAST
|
||||||
} ParameterError;
|
} ParameterError;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
|
@ -66,6 +66,8 @@ const char *param2text(int res)
|
||||||
return "the given option can't be reversed with a --no- prefix";
|
return "the given option can't be reversed with a --no- prefix";
|
||||||
case PARAM_NUMBER_TOO_LARGE:
|
case PARAM_NUMBER_TOO_LARGE:
|
||||||
return "too large number";
|
return "too large number";
|
||||||
|
case PARAM_NO_NOT_BOOLEAN:
|
||||||
|
return "used '--no-' for option that isn't a boolean";
|
||||||
default:
|
default:
|
||||||
return "unknown error";
|
return "unknown error";
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ test289 test290 test291 test292 test293 test294 test295 test296 test297 \
|
||||||
test298 test299 test300 test301 test302 test303 test304 test305 test306 \
|
test298 test299 test300 test301 test302 test303 test304 test305 test306 \
|
||||||
test307 test308 test309 test310 test311 test312 test313 test314 test315 \
|
test307 test308 test309 test310 test311 test312 test313 test314 test315 \
|
||||||
test316 test317 test318 test319 test320 test321 test322 test323 test324 \
|
test316 test317 test318 test319 test320 test321 test322 test323 test324 \
|
||||||
test325 test326 test327 test328 test329 test330 test331 test332 \
|
test325 test326 test327 test328 test329 test330 test331 test332 test333 \
|
||||||
\
|
\
|
||||||
test340 \
|
test340 \
|
||||||
\
|
\
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<testcase>
|
||||||
|
<info>
|
||||||
|
<keywords>
|
||||||
|
command-line
|
||||||
|
</keywords>
|
||||||
|
</info>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<server>
|
||||||
|
none
|
||||||
|
</server>
|
||||||
|
<name>
|
||||||
|
Try a non-boolean command line option with --no-
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
--no-proxy "hey" http://%HOSTIP:%HTTPPORT/333
|
||||||
|
</command>
|
||||||
|
</client>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
# detected the bad --no- prefix
|
||||||
|
<errorcode>
|
||||||
|
2
|
||||||
|
</errorcode>
|
||||||
|
</verify>
|
||||||
|
</testcase>
|
Loading…
Reference in New Issue