mirror of
https://github.com/moparisthebest/curl
synced 2025-01-11 05:58:01 -05:00
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;
|
||||
size_t fnam = strlen(word);
|
||||
int numhits = 0;
|
||||
bool noflagged = FALSE;
|
||||
|
||||
if(!strncmp(word, "no-", 3)) {
|
||||
/* disable this option but ignore the "no-" part when looking for it */
|
||||
word += 3;
|
||||
toggle = FALSE;
|
||||
noflagged = TRUE;
|
||||
}
|
||||
|
||||
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) {
|
||||
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 {
|
||||
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
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -42,6 +42,7 @@ typedef enum {
|
||||
PARAM_NEXT_OPERATION,
|
||||
PARAM_NO_PREFIX,
|
||||
PARAM_NUMBER_TOO_LARGE,
|
||||
PARAM_NO_NOT_BOOLEAN,
|
||||
PARAM_LAST
|
||||
} 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
|
||||
* 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";
|
||||
case PARAM_NUMBER_TOO_LARGE:
|
||||
return "too large number";
|
||||
case PARAM_NO_NOT_BOOLEAN:
|
||||
return "used '--no-' for option that isn't a boolean";
|
||||
default:
|
||||
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 \
|
||||
test307 test308 test309 test310 test311 test312 test313 test314 test315 \
|
||||
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 \
|
||||
\
|
||||
|
35
tests/data/test333
Normal file
35
tests/data/test333
Normal file
@ -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
Block a user