diff --git a/include/CLI/impl/App_inl.hpp b/include/CLI/impl/App_inl.hpp index 1e1d9f52..614805dd 100644 --- a/include/CLI/impl/App_inl.hpp +++ b/include/CLI/impl/App_inl.hpp @@ -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 buffer; // a buffer to use for copying an modifying inputs in a few cases + std::vector 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()) { diff --git a/include/CLI/impl/Config_inl.hpp b/include/CLI/impl/Config_inl.hpp index 19bb1587..97e3fd44 100644 --- a/include/CLI/impl/Config_inl.hpp +++ b/include/CLI/impl/Config_inl.hpp @@ -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) { diff --git a/tests/FuzzFailTest.cpp b/tests/FuzzFailTest.cpp index 2433682d..5ce616eb 100644 --- a/tests/FuzzFailTest.cpp +++ b/tests/FuzzFailTest.cpp @@ -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); diff --git a/tests/fuzzFail/round_trip_custom24 b/tests/fuzzFail/round_trip_custom24 new file mode 100644 index 00000000..492ca4e7 Binary files /dev/null and b/tests/fuzzFail/round_trip_custom24 differ