Skip to content

Commit

Permalink
fix: Don't forward ledger API if 'full' is a string (#1640)
Browse files Browse the repository at this point in the history
Fix #1635
  • Loading branch information
cindyyan317 committed Sep 9, 2024
1 parent 0054e4b commit d02d6af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/rpc/RPCHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1276,8 +1276,10 @@ specifiesCurrentOrClosedLedger(boost::json::object const& request)
bool
isAdminCmd(std::string const& method, boost::json::object const& request)
{
// rippled considers the string as true: https://github.com/XRPLF/rippled/issues/5119
auto const isFieldSet = [&request](auto const field) {
return request.contains(field) and request.at(field).is_bool() and request.at(field).as_bool();
return request.contains(field) and
((request.at(field).is_bool() and request.at(field).as_bool()) or request.at(field).is_string());
};

if (method == JS(ledger)) {
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/rpc/RPCHelpersTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,11 @@ generateTestValuesForParametersTest()
{"ledgerFullFalse", "ledger", R"({"full": false})", false},
{"ledgerAccountsFalse", "ledger", R"({"accounts": false})", false},
{"ledgerTypeFalse", "ledger", R"({"type": false})", false},
{"ledgerEntry", "ledger_entry", R"({"type": false})", false}
{"ledgerEntry", "ledger_entry", R"({"type": false})", false},
{"ledgerFullIsStr", "ledger", R"({"full": "String"})", true},
{"ledgerAccoutsIsStr", "ledger", R"({"accounts": "String"})", true},
{"ledgerTypeIsStr", "ledger", R"({"type": "String"})", true},
{"featureVetoedIsStr", "feature", R"({"vetoed": "String"})", true},
};
}

Expand Down

0 comments on commit d02d6af

Please sign in to comment.