Skip to content

Commit de319c6

Browse files
committed
RPC/rpcdoccheck: Error if a oneline_description has a quote for a non-string
1 parent 7c61e9d commit de319c6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/rpc/util.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,16 @@ std::string RPCArg::ToStringObj(const bool oneline) const
11171117

11181118
std::string RPCArg::ToString(const bool oneline) const
11191119
{
1120-
if (oneline && !m_opts.oneline_description.empty()) return m_opts.oneline_description;
1120+
if (oneline && !m_opts.oneline_description.empty()) {
1121+
if (m_opts.oneline_description[0] == '\"' && m_type != Type::STR_HEX && m_type != Type::STR && gArgs.GetBoolArg("-rpcdoccheck", DEFAULT_RPC_DOC_CHECK)) {
1122+
throw std::runtime_error{
1123+
strprintf("Internal bug detected: non-string RPC arg \"%s\" quotes oneline_description:\n%s\n%s %s\nPlease report this issue here: %s\n",
1124+
m_names, m_opts.oneline_description,
1125+
PACKAGE_NAME, FormatFullVersion(),
1126+
PACKAGE_BUGREPORT)};
1127+
}
1128+
return m_opts.oneline_description;
1129+
}
11211130

11221131
switch (m_type) {
11231132
case Type::STR_HEX:

0 commit comments

Comments
 (0)