Fuzzer issues (#1202)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Philip Top
2025-09-02 07:07:01 -07:00
committed by GitHub
parent dd99ec7752
commit ee326d647b
4 changed files with 12 additions and 4 deletions

View File

@@ -1670,7 +1670,7 @@ CLI11_INLINE bool App::_parse_single_config(const ConfigItem &item, std::size_t
throw ConfigError::NotConfigurable(item.fullname());
}
if(op->empty()) {
std::vector<std::string> buffer; // a buffer to use for copying an modifying inputs in a few cases
std::vector<std::string> buffer; // a buffer to use for copying and modifying inputs in a few cases
bool useBuffer{false};
if(item.multiline) {
if(!op->get_inject_separator()) {

View File

@@ -584,8 +584,16 @@ ConfigBase::to_config(const App *app, bool default_also, bool write_description,
}
}
}
std::string value =
detail::ini_join(results, arraySeparator, arrayStart, arrayEnd, stringQuote, literalQuote);
std::string value;
if(opt->count() == 1 && results.size() == 2 && results.front() == "{}" && results.back() == "%%") {
// there is a catch to allow for {} to used as as string in the output
// it will append a sequence terminator to the output so the lexical conversion handles it
// correctly but that is meant for config files so when outputting for a config file we need to
// makes sure to get the correct output
value = "\"{}\"";
} else {
value = detail::ini_join(results, arraySeparator, arrayStart, arrayEnd, stringQuote, literalQuote);
}
bool isDefault = false;
if(value.empty() && default_also) {

View File

@@ -345,7 +345,7 @@ TEST_CASE("app_roundtrip_custom") {
CLI::FuzzApp fuzzdata2;
auto app = fuzzdata.generateApp();
auto app2 = fuzzdata2.generateApp();
int index = GENERATE(range(1, 24));
int index = GENERATE(range(1, 25));
auto parseData = loadFailureFile("round_trip_custom", index);

Binary file not shown.