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++) {
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 */
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * 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
PARAM_NEXT_OPERATION,
PARAM_NO_PREFIX,
PARAM_NUMBER_TOO_LARGE,
+ PARAM_NO_NOT_BOOLEAN,
PARAM_LAST
} ParameterError;
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * 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
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";
}
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 \
\
--- /dev/null
+<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>