Merge #17482: util: Disallow network-qualified command line options

900d8f6f70 util: Disallow network-qualified command line options (Russell Yanofsky)

Pull request description:

  Previously these were allowed but ignored.

  This change implements one of the settings simplifications listed in #17508. Change includes release notes.

ACKs for top commit:
  laanwj:
    ACK 900d8f6f70

Tree-SHA512: ab020a16a86c1e8ec709fbf798d533879d32c565eceeb7eb785c33042c49c6b4d1108c5453d8166e4a2abffc2c8802fbb6d3b895e0ddeefa8f274fd647e3c8ad
This commit is contained in:
Wladimir J. van der Laan
2020-02-05 15:46:55 +01:00
4 changed files with 42 additions and 16 deletions

View File

@@ -312,21 +312,18 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
std::string section;
util::SettingsValue value = InterpretOption(section, key, val);
Optional<unsigned int> flags = GetArgFlags('-' + key);
if (flags) {
if (!CheckValid(key, value, *flags, error)) {
return false;
}
// Weird behavior preserved for backwards compatibility: command
// line options with section prefixes are allowed but ignored. It
// would be better if these options triggered the Invalid parameter
// error below.
if (section.empty()) {
m_settings.command_line_options[key].push_back(value);
}
} else {
error = strprintf("Invalid parameter -%s", key);
// Unknown command line options and command line options with dot
// characters (which are returned from InterpretOption with nonempty
// section strings) are not valid.
if (!flags || !section.empty()) {
error = strprintf("Invalid parameter %s", argv[i]);
return false;
}
if (!CheckValid(key, value, *flags, error)) return false;
m_settings.command_line_options[key].push_back(value);
}
// we do not allow -includeconf from command line