From de319c61759952318364fbcb28c47f0959d89d0e Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 22 Jul 2023 01:03:56 +0000 Subject: [PATCH] RPC/rpcdoccheck: Error if a oneline_description has a quote for a non-string --- src/rpc/util.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 19e14f88df..45bc54ee17 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -1117,7 +1117,16 @@ std::string RPCArg::ToStringObj(const bool oneline) const std::string RPCArg::ToString(const bool oneline) const { - if (oneline && !m_opts.oneline_description.empty()) return m_opts.oneline_description; + if (oneline && !m_opts.oneline_description.empty()) { + if (m_opts.oneline_description[0] == '\"' && m_type != Type::STR_HEX && m_type != Type::STR && gArgs.GetBoolArg("-rpcdoccheck", DEFAULT_RPC_DOC_CHECK)) { + throw std::runtime_error{ + strprintf("Internal bug detected: non-string RPC arg \"%s\" quotes oneline_description:\n%s\n%s %s\nPlease report this issue here: %s\n", + m_names, m_opts.oneline_description, + PACKAGE_NAME, FormatFullVersion(), + PACKAGE_BUGREPORT)}; + } + return m_opts.oneline_description; + } switch (m_type) { case Type::STR_HEX: