Skip to content

Commit ee326d6

Browse files
Fuzzer issues (#1202)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent dd99ec7 commit ee326d6

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

include/CLI/impl/App_inl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ CLI11_INLINE bool App::_parse_single_config(const ConfigItem &item, std::size_t
16701670
throw ConfigError::NotConfigurable(item.fullname());
16711671
}
16721672
if(op->empty()) {
1673-
std::vector<std::string> buffer; // a buffer to use for copying an modifying inputs in a few cases
1673+
std::vector<std::string> buffer; // a buffer to use for copying and modifying inputs in a few cases
16741674
bool useBuffer{false};
16751675
if(item.multiline) {
16761676
if(!op->get_inject_separator()) {

include/CLI/impl/Config_inl.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,16 @@ ConfigBase::to_config(const App *app, bool default_also, bool write_description,
584584
}
585585
}
586586
}
587-
std::string value =
588-
detail::ini_join(results, arraySeparator, arrayStart, arrayEnd, stringQuote, literalQuote);
587+
std::string value;
588+
if(opt->count() == 1 && results.size() == 2 && results.front() == "{}" && results.back() == "%%") {
589+
// there is a catch to allow for {} to used as as string in the output
590+
// it will append a sequence terminator to the output so the lexical conversion handles it
591+
// correctly but that is meant for config files so when outputting for a config file we need to
592+
// makes sure to get the correct output
593+
value = "\"{}\"";
594+
} else {
595+
value = detail::ini_join(results, arraySeparator, arrayStart, arrayEnd, stringQuote, literalQuote);
596+
}
589597

590598
bool isDefault = false;
591599
if(value.empty() && default_also) {

tests/FuzzFailTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ TEST_CASE("app_roundtrip_custom") {
345345
CLI::FuzzApp fuzzdata2;
346346
auto app = fuzzdata.generateApp();
347347
auto app2 = fuzzdata2.generateApp();
348-
int index = GENERATE(range(1, 24));
348+
int index = GENERATE(range(1, 25));
349349

350350
auto parseData = loadFailureFile("round_trip_custom", index);
351351

tests/fuzzFail/round_trip_custom24

141 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)