mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-24 00:23:38 +00:00
Moved JSON output validation to httpd.c.
This commit is contained in:
parent
177bf03e10
commit
997b17d854
2 changed files with 10 additions and 8 deletions
10
httpd.c
10
httpd.c
|
@ -266,6 +266,16 @@ void httpd_connection(FILE *f)
|
|||
|
||||
srv_archive("RECV", NULL, req, payload, p_size, status, headers, body, b_size);
|
||||
|
||||
/* JSON validation check */
|
||||
if (strcmp(ctype, "application/json") == 0) {
|
||||
xs *j = xs_json_loads(body);
|
||||
|
||||
if (j == NULL) {
|
||||
srv_log(xs_fmt("bad JSON"));
|
||||
srv_archive_error("bad_json", "bad JSON", req, body);
|
||||
}
|
||||
}
|
||||
|
||||
xs_free(body);
|
||||
}
|
||||
|
||||
|
|
|
@ -900,14 +900,6 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|||
*ctype = "application/json";
|
||||
status = 200;
|
||||
|
||||
{
|
||||
xs *j = xs_json_loads(*body);
|
||||
if (j == NULL) {
|
||||
srv_log(xs_fmt("mastoapi timeline: bad JSON"));
|
||||
srv_archive_error("mastoapi_timeline", "bad JSON", req, *body);
|
||||
}
|
||||
}
|
||||
|
||||
srv_debug(2, xs_fmt("mastoapi timeline: returned %d entries", xs_list_len(out)));
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in a new issue