From 7d0753f1daa26873b82d8301105b89174c34d191 Mon Sep 17 00:00:00 2001 From: cyan317 <120398799+cindyyan317@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:20:02 +0100 Subject: [PATCH] fix: Don't forward ledger API if 'full' is a string (#1640) Fix #1635 --- src/rpc/RPCHelpers.cpp | 4 +++- tests/unit/rpc/RPCHelpersTests.cpp | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rpc/RPCHelpers.cpp b/src/rpc/RPCHelpers.cpp index e4d169afa..5b0119df3 100644 --- a/src/rpc/RPCHelpers.cpp +++ b/src/rpc/RPCHelpers.cpp @@ -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)) { diff --git a/tests/unit/rpc/RPCHelpersTests.cpp b/tests/unit/rpc/RPCHelpersTests.cpp index 85dd4782d..a70dd6b41 100644 --- a/tests/unit/rpc/RPCHelpersTests.cpp +++ b/tests/unit/rpc/RPCHelpersTests.cpp @@ -562,7 +562,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}, }; }