summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorPaul Wilde <psw@wildefedi01.wildenet.wilde.cloud>2024-01-26 23:14:27 +0000
committerPaul Wilde <psw@wildefedi01.wildenet.wilde.cloud>2024-01-26 23:14:27 +0000
commit2410c73d9a4e4bdcecab39c5073565b3115b96c1 (patch)
tree0b775cd59c7927a29f279379150ee5f76374b621 /mastoapi.c
parent1060baa6ca31f53fdfe54d44a4d6eabbff87eb5c (diff)
parentd5c2c442b162da388ae3fa274b44ec676cbca2c4 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 9f6c383..d8ec3b3 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -240,8 +240,10 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
char *i_ctype = xs_dict_get(req, "content-type");
xs *args = NULL;
- if (i_ctype && xs_startswith(i_ctype, "application/json"))
- args = xs_json_loads(payload);
+ if (i_ctype && xs_startswith(i_ctype, "application/json")) {
+ if (!xs_is_null(payload))
+ args = xs_json_loads(payload);
+ }
else
if (i_ctype && xs_startswith(i_ctype, "application/x-www-form-urlencoded") && payload) {
xs *upl = xs_url_dec(payload);
@@ -250,6 +252,9 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
else
args = xs_dup(xs_dict_get(req, "p_vars"));
+ if (args == NULL)
+ return 400;
+
xs *cmd = xs_replace_n(q_path, "/oauth", "", 1);
srv_debug(1, xs_fmt("oauth_post_handler %s", q_path));
@@ -1981,8 +1986,10 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
xs *args = NULL;
char *i_ctype = xs_dict_get(req, "content-type");
- if (i_ctype && xs_startswith(i_ctype, "application/json"))
- args = xs_json_loads(payload);
+ if (i_ctype && xs_startswith(i_ctype, "application/json")) {
+ if (!xs_is_null(payload))
+ args = xs_json_loads(payload);
+ }
else
args = xs_dup(xs_dict_get(req, "p_vars"));
@@ -2504,8 +2511,10 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path,
xs *args = NULL;
char *i_ctype = xs_dict_get(req, "content-type");
- if (i_ctype && xs_startswith(i_ctype, "application/json"))
- args = xs_json_loads(payload);
+ if (i_ctype && xs_startswith(i_ctype, "application/json")) {
+ if (!xs_is_null(payload))
+ args = xs_json_loads(payload);
+ }
else
args = xs_dup(xs_dict_get(req, "p_vars"));