rpc: Quote user supplied strings in error messages

This commit is contained in:
MarcoFalke
2021-12-13 09:52:13 +01:00
parent 767c012665
commit fa24a3df87
4 changed files with 8 additions and 8 deletions

View File

@@ -1134,7 +1134,7 @@ CoinStatsHashType ParseHashType(const std::string& hash_type_input)
} else if (hash_type_input == "none") {
return CoinStatsHashType::NONE;
} else {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("%s is not a valid hash_type", hash_type_input));
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("'%s' is not a valid hash_type", hash_type_input));
}
}
@@ -2213,7 +2213,7 @@ static RPCHelpMan getblockstats()
for (const std::string& stat : stats) {
const UniValue& value = ret_all[stat];
if (value.isNull()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid selected statistic %s", stat));
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid selected statistic '%s'", stat));
}
ret.pushKV(stat, value);
}