mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-04 12:42:05 +02:00
rest: Use SAFE_CHARS_URI in SanitizeString error msg
When dealing with URI parts, it seems more consistent to use corresponding SAFE_CHARS_URI mode in error messages. Co-Authored-By: stickies-v <stickies-v@protonmail.com>
This commit is contained in:
@ -964,7 +964,7 @@ static bool rest_blockhash_by_height(const std::any& context, HTTPRequest* req,
|
|||||||
|
|
||||||
const auto blockheight{ToIntegral<int32_t>(height_str)};
|
const auto blockheight{ToIntegral<int32_t>(height_str)};
|
||||||
if (!blockheight || *blockheight < 0) {
|
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;
|
CBlockIndex* pblockindex = nullptr;
|
||||||
|
@ -272,7 +272,7 @@ class RESTTest (BitcoinTestFramework):
|
|||||||
resp = self.test_rest_request(f"/blockhashbyheight/{INVALID_PARAM}", ret_type=RetType.OBJ, status=400)
|
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}")
|
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)
|
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)
|
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")
|
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)
|
resp = self.test_rest_request("/blockhashbyheight/-1", ret_type=RetType.OBJ, status=400)
|
||||||
|
Reference in New Issue
Block a user