cpprestsdk
cpprestsdk copied to clipboard
http_request::extract_json() crashes if malformed JSON is provided.
OS: Ubuntu 20.04.2 Compiler: GCC 9.4.0
Example
{
"user_id": 1,sasd123
"post_id": 16
}
I also had this issue and came across this
void handle_post(http_request request) {
request.extract_json().then([request](pplx::task<web::json::value> task) {
try {
auto body = task.get(); // Exception occurs
...
} catch (const std::exception& e) {
ucout << e.what() << std::endl; // Example: Line 1, Column 3 Syntax error: Malformed token
...
}
request.reply(status_codes::OK, U("OK"));
});
}