Open Mis1eader-dev opened 3 months ago
In case this issue gets tackled, there is std::from_chars
for ASCII to primitive number type conversion, which resides in the <charconv>
header.
A proper checker would look like this:
string_view param = "123d";
uint64_t num;
if(std::from_chars(param.begin(), param.end(), num).ptr != param.end())
return error;
// success, do something with [num]
Describe the bug Creating an
HttpController
with methods that take inuint64_t
for example, and making a request to -1 will underflow and becomeUINT64_MAX
. Another related bug is if the URL contains characters, it still processes it.Expected behavior Should give 400 Bad Request upon error.
Desktop (please complete the following information):
Additional context For the time being the only choice is to take by string and do validation manually.