diff options
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 21 |
1 files changed, 15 insertions, 6 deletions
| @@ -240,8 +240,10 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 240 | char *i_ctype = xs_dict_get(req, "content-type"); | 240 | char *i_ctype = xs_dict_get(req, "content-type"); |
| 241 | xs *args = NULL; | 241 | xs *args = NULL; |
| 242 | 242 | ||
| 243 | if (i_ctype && xs_startswith(i_ctype, "application/json")) | 243 | if (i_ctype && xs_startswith(i_ctype, "application/json")) { |
| 244 | args = xs_json_loads(payload); | 244 | if (!xs_is_null(payload)) |
| 245 | args = xs_json_loads(payload); | ||
| 246 | } | ||
| 245 | else | 247 | else |
| 246 | if (i_ctype && xs_startswith(i_ctype, "application/x-www-form-urlencoded") && payload) { | 248 | if (i_ctype && xs_startswith(i_ctype, "application/x-www-form-urlencoded") && payload) { |
| 247 | xs *upl = xs_url_dec(payload); | 249 | xs *upl = xs_url_dec(payload); |
| @@ -250,6 +252,9 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 250 | else | 252 | else |
| 251 | args = xs_dup(xs_dict_get(req, "p_vars")); | 253 | args = xs_dup(xs_dict_get(req, "p_vars")); |
| 252 | 254 | ||
| 255 | if (args == NULL) | ||
| 256 | return 400; | ||
| 257 | |||
| 253 | xs *cmd = xs_replace_n(q_path, "/oauth", "", 1); | 258 | xs *cmd = xs_replace_n(q_path, "/oauth", "", 1); |
| 254 | 259 | ||
| 255 | srv_debug(1, xs_fmt("oauth_post_handler %s", q_path)); | 260 | 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, | |||
| 1981 | xs *args = NULL; | 1986 | xs *args = NULL; |
| 1982 | char *i_ctype = xs_dict_get(req, "content-type"); | 1987 | char *i_ctype = xs_dict_get(req, "content-type"); |
| 1983 | 1988 | ||
| 1984 | if (i_ctype && xs_startswith(i_ctype, "application/json")) | 1989 | if (i_ctype && xs_startswith(i_ctype, "application/json")) { |
| 1985 | args = xs_json_loads(payload); | 1990 | if (!xs_is_null(payload)) |
| 1991 | args = xs_json_loads(payload); | ||
| 1992 | } | ||
| 1986 | else | 1993 | else |
| 1987 | args = xs_dup(xs_dict_get(req, "p_vars")); | 1994 | args = xs_dup(xs_dict_get(req, "p_vars")); |
| 1988 | 1995 | ||
| @@ -2504,8 +2511,10 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path, | |||
| 2504 | xs *args = NULL; | 2511 | xs *args = NULL; |
| 2505 | char *i_ctype = xs_dict_get(req, "content-type"); | 2512 | char *i_ctype = xs_dict_get(req, "content-type"); |
| 2506 | 2513 | ||
| 2507 | if (i_ctype && xs_startswith(i_ctype, "application/json")) | 2514 | if (i_ctype && xs_startswith(i_ctype, "application/json")) { |
| 2508 | args = xs_json_loads(payload); | 2515 | if (!xs_is_null(payload)) |
| 2516 | args = xs_json_loads(payload); | ||
| 2517 | } | ||
| 2509 | else | 2518 | else |
| 2510 | args = xs_dup(xs_dict_get(req, "p_vars")); | 2519 | args = xs_dup(xs_dict_get(req, "p_vars")); |
| 2511 | 2520 | ||