mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 15:05:53 +00:00
fix can_delete
This commit is contained in:
@@ -1948,8 +1948,16 @@ static RPCCallTestData const rpcCallTestArray[] = {
|
||||
"can_delete",
|
||||
"4294967296",
|
||||
},
|
||||
RPCCallTestData::bad_cast,
|
||||
R"()"},
|
||||
RPCCallTestData::no_exception,
|
||||
R"({
|
||||
"method" : "can_delete",
|
||||
"params" : [
|
||||
{
|
||||
"error" : "invalidParams",
|
||||
"error_message" : "Invalid field 'can_delete'."
|
||||
}
|
||||
]
|
||||
})"},
|
||||
{// Note: this really shouldn't throw since it's a legitimate ledger hash.
|
||||
"can_delete: ledger hash with no alphas.",
|
||||
__LINE__,
|
||||
@@ -1957,8 +1965,16 @@ static RPCCallTestData const rpcCallTestArray[] = {
|
||||
"can_delete",
|
||||
"0123456701234567012345670123456701234567012345670123456701234567",
|
||||
},
|
||||
RPCCallTestData::bad_cast,
|
||||
R"()"},
|
||||
RPCCallTestData::no_exception,
|
||||
R"({
|
||||
"method" : "can_delete",
|
||||
"params" : [
|
||||
{
|
||||
"error" : "invalidParams",
|
||||
"error_message" : "Invalid field 'can_delete'."
|
||||
}
|
||||
]
|
||||
})"},
|
||||
|
||||
// channel_authorize
|
||||
// -----------------------------------------------------------
|
||||
|
||||
@@ -135,7 +135,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
static std::optional<std::uint32_t>
|
||||
static std::optional<std::int32_t>
|
||||
jvParseInt(Json::Value const& param)
|
||||
{
|
||||
if (param.isUInt() || param.isInt())
|
||||
@@ -151,6 +151,22 @@ private:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
static std::optional<std::uint32_t>
|
||||
jvParseUInt(Json::Value const& param)
|
||||
{
|
||||
if (param.isUInt() || (param.isInt() && param.asInt() >= 0))
|
||||
return param.asUInt();
|
||||
|
||||
if (param.isString())
|
||||
{
|
||||
std::uint32_t v;
|
||||
if (beast::lexicalCastChecked(v, param.asString()))
|
||||
return v;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
static bool
|
||||
validPublicKey(
|
||||
std::string const& strPk,
|
||||
@@ -418,7 +434,12 @@ private:
|
||||
|
||||
std::string input = jvParams[0u].asString();
|
||||
if (input.find_first_not_of("0123456789") == std::string::npos)
|
||||
jvRequest["can_delete"] = jvParams[0u].asUInt();
|
||||
{
|
||||
if (auto seq = jvParseUInt(jvParams[0u]))
|
||||
jvRequest["can_delete"] = *seq;
|
||||
else
|
||||
return RPC::invalid_field_error(jss::can_delete);
|
||||
}
|
||||
else
|
||||
jvRequest["can_delete"] = input;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user