summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-04-23 15:37:09 +0200
committerGravatar default2023-04-23 15:37:09 +0200
commit997b17d854db1709686df85fe8dedae0a20ca5fa (patch)
tree0f8399c1789f47d1138b1a072400b2491911e47a
parentFixed bad JSON for accounts that do not have a 'summary' field. (diff)
downloadsnac2-997b17d854db1709686df85fe8dedae0a20ca5fa.tar.gz
snac2-997b17d854db1709686df85fe8dedae0a20ca5fa.tar.xz
snac2-997b17d854db1709686df85fe8dedae0a20ca5fa.zip
Moved JSON output validation to httpd.c.
-rw-r--r--httpd.c10
-rw-r--r--mastoapi.c8
2 files changed, 10 insertions, 8 deletions
diff --git a/httpd.c b/httpd.c
index 79d489f..70083a1 100644
--- a/httpd.c
+++ b/httpd.c
@@ -266,6 +266,16 @@ void httpd_connection(FILE *f)
266 266
267 srv_archive("RECV", NULL, req, payload, p_size, status, headers, body, b_size); 267 srv_archive("RECV", NULL, req, payload, p_size, status, headers, body, b_size);
268 268
269 /* JSON validation check */
270 if (strcmp(ctype, "application/json") == 0) {
271 xs *j = xs_json_loads(body);
272
273 if (j == NULL) {
274 srv_log(xs_fmt("bad JSON"));
275 srv_archive_error("bad_json", "bad JSON", req, body);
276 }
277 }
278
269 xs_free(body); 279 xs_free(body);
270} 280}
271 281
diff --git a/mastoapi.c b/mastoapi.c
index 06ec915..cf52e5d 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -900,14 +900,6 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
900 *ctype = "application/json"; 900 *ctype = "application/json";
901 status = 200; 901 status = 200;
902 902
903 {
904 xs *j = xs_json_loads(*body);
905 if (j == NULL) {
906 srv_log(xs_fmt("mastoapi timeline: bad JSON"));
907 srv_archive_error("mastoapi_timeline", "bad JSON", req, *body);
908 }
909 }
910
911 srv_debug(2, xs_fmt("mastoapi timeline: returned %d entries", xs_list_len(out))); 903 srv_debug(2, xs_fmt("mastoapi timeline: returned %d entries", xs_list_len(out)));
912 } 904 }
913 else { 905 else {