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