Skip to content

Commit fab06ac

Browse files
MarcoFalkestickies-v
andcommitted
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 <[email protected]>
1 parent 8888bb4 commit fab06ac

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/rest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ static bool rest_blockhash_by_height(const std::any& context, HTTPRequest* req,
964964

965965
const auto blockheight{ToIntegral<int32_t>(height_str)};
966966
if (!blockheight || *blockheight < 0) {
967-
return RESTERR(req, HTTP_BAD_REQUEST, "Invalid height: " + SanitizeString(height_str));
967+
return RESTERR(req, HTTP_BAD_REQUEST, "Invalid height: " + SanitizeString(height_str, SAFE_CHARS_URI));
968968
}
969969

970970
CBlockIndex* pblockindex = nullptr;

test/functional/interface_rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def run_test(self):
272272
resp = self.test_rest_request(f"/blockhashbyheight/{INVALID_PARAM}", ret_type=RetType.OBJ, status=400)
273273
assert_equal(resp.read().decode('utf-8').rstrip(), f"Invalid height: {INVALID_PARAM}")
274274
resp = self.test_rest_request("/blockhashbyheight/+1", ret_type=RetType.OBJ, status=400)
275-
assert_equal(resp.read().decode('utf-8').rstrip(), "Invalid height: 1")
275+
assert_equal(resp.read().decode('utf-8').rstrip(), "Invalid height: +1")
276276
resp = self.test_rest_request("/blockhashbyheight/1000000", ret_type=RetType.OBJ, status=404)
277277
assert_equal(resp.read().decode('utf-8').rstrip(), "Block height out of range")
278278
resp = self.test_rest_request("/blockhashbyheight/-1", ret_type=RetType.OBJ, status=400)

0 commit comments

Comments
 (0)