If we use SAFE_CHARS_URI
here (seems appropriate since we’re dealing with a uri) the +
sign is returned in the error description:
0diff --git a/src/rest.cpp b/src/rest.cpp
1index b340567bd1..464880224c 100644
2--- a/src/rest.cpp
3+++ b/src/rest.cpp
4@@ -964,7 +964,7 @@ static bool rest_blockhash_by_height(const std::any& context, HTTPRequest* req,
5
6 const auto blockheight{ToIntegral<int32_t>(height_str)};
7 if (!blockheight || *blockheight < 0) {
8- return RESTERR(req, HTTP_BAD_REQUEST, "Invalid height: " + SanitizeString(height_str));
9+ return RESTERR(req, HTTP_BAD_REQUEST, "Invalid height: " + SanitizeString(height_str, SAFE_CHARS_URI));
10 }
11
12 CBlockIndex* pblockindex = nullptr;
13diff --git a/test/functional/interface_rest.py b/test/functional/interface_rest.py
14index ff76697884..a853b2ec0e 100755
15--- a/test/functional/interface_rest.py
16+++ b/test/functional/interface_rest.py
17@@ -272,7 +272,7 @@ class RESTTest (BitcoinTestFramework):
18 resp = self.test_rest_request(f"/blockhashbyheight/{INVALID_PARAM}", ret_type=RetType.OBJ, status=400)
19 assert_equal(resp.read().decode('utf-8').rstrip(), f"Invalid height: {INVALID_PARAM}")
20 resp = self.test_rest_request("/blockhashbyheight/+1", ret_type=RetType.OBJ, status=400)
21- assert_equal(resp.read().decode('utf-8').rstrip(), "Invalid height: 1")
22+ assert_equal(resp.read().decode('utf-8').rstrip(), "Invalid height: +1")
23 resp = self.test_rest_request("/blockhashbyheight/1000000", ret_type=RetType.OBJ, status=404)
24 assert_equal(resp.read().decode('utf-8').rstrip(), "Block height out of range")
25 resp = self.test_rest_request("/blockhashbyheight/-1", ret_type=RetType.OBJ, status=400)