Skip to content

Commit

Permalink
[RPC] require valid URL scheme on budget commands
Browse files Browse the repository at this point in the history
  • Loading branch information
CaveSpectre11 committed Jul 26, 2019
1 parent 9e4c357 commit ea79cad
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/rpc/budget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ UniValue preparebudget(const UniValue& params, bool fHelp)
if (strURL.size() > 64)
throw std::runtime_error("Invalid url, limit of 64 characters.");

if ((strURL.front() == 'h') || (strURL.front() == 'H')) {
std::size_t found = strURL.find("ttp://") == 1 ? strURL.find("ttp://") : strURL.find("ttps://");
if (found != 1)
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid url, add scheme (e.g. https://)"));
} else {
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid url, add scheme (e.g. https://)"));
}

int nPaymentCount = params[2].get_int();
if (nPaymentCount < 1)
throw std::runtime_error("Invalid payment count, must be more than zero.");
Expand Down Expand Up @@ -180,6 +188,14 @@ UniValue submitbudget(const UniValue& params, bool fHelp)
if (strURL.size() > 64)
throw std::runtime_error("Invalid url, limit of 64 characters.");

if ((strURL.front() == 'h') || (strURL.front() == 'H')) {
std::size_t found = strURL.find("ttp://") == 1 ? strURL.find("ttp://") : strURL.find("ttps://");
if (found != 1)
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid url, add scheme (e.g. https://)"));
} else {
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid url, add scheme (e.g. https://)"));
}

int nPaymentCount = params[2].get_int();
if (nPaymentCount < 1)
throw std::runtime_error("Invalid payment count, must be more than zero.");
Expand Down

0 comments on commit ea79cad

Please sign in to comment.