mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
mastoapi: fix crashes on unset content-type.
This commit is contained in:
parent
9a1fc7980c
commit
7a6b94a058
1 changed files with 15 additions and 0 deletions
15
mastoapi.c
15
mastoapi.c
|
@ -243,6 +243,9 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
|
||||||
const char *i_ctype = xs_dict_get(req, "content-type");
|
const char *i_ctype = xs_dict_get(req, "content-type");
|
||||||
xs *args = NULL;
|
xs *args = NULL;
|
||||||
|
|
||||||
|
if (i_ctype == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (i_ctype && xs_startswith(i_ctype, "application/json")) {
|
if (i_ctype && xs_startswith(i_ctype, "application/json")) {
|
||||||
if (!xs_is_null(payload))
|
if (!xs_is_null(payload))
|
||||||
args = xs_json_loads(payload);
|
args = xs_json_loads(payload);
|
||||||
|
@ -2412,6 +2415,9 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
|
||||||
xs *args = NULL;
|
xs *args = NULL;
|
||||||
const char *i_ctype = xs_dict_get(req, "content-type");
|
const char *i_ctype = xs_dict_get(req, "content-type");
|
||||||
|
|
||||||
|
if (i_ctype == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (i_ctype && xs_startswith(i_ctype, "application/json")) {
|
if (i_ctype && xs_startswith(i_ctype, "application/json")) {
|
||||||
if (!xs_is_null(payload))
|
if (!xs_is_null(payload))
|
||||||
args = xs_json_loads(payload);
|
args = xs_json_loads(payload);
|
||||||
|
@ -3000,6 +3006,9 @@ int mastoapi_delete_handler(const xs_dict *req, const char *q_path,
|
||||||
xs *args = NULL;
|
xs *args = NULL;
|
||||||
const char *i_ctype = xs_dict_get(req, "content-type");
|
const char *i_ctype = xs_dict_get(req, "content-type");
|
||||||
|
|
||||||
|
if (i_ctype == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (i_ctype && xs_startswith(i_ctype, "application/json")) {
|
if (i_ctype && xs_startswith(i_ctype, "application/json")) {
|
||||||
if (!xs_is_null(payload))
|
if (!xs_is_null(payload))
|
||||||
args = xs_json_loads(payload);
|
args = xs_json_loads(payload);
|
||||||
|
@ -3088,6 +3097,9 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path,
|
||||||
xs *args = NULL;
|
xs *args = NULL;
|
||||||
const char *i_ctype = xs_dict_get(req, "content-type");
|
const char *i_ctype = xs_dict_get(req, "content-type");
|
||||||
|
|
||||||
|
if (i_ctype == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (i_ctype && xs_startswith(i_ctype, "application/json")) {
|
if (i_ctype && xs_startswith(i_ctype, "application/json")) {
|
||||||
if (!xs_is_null(payload))
|
if (!xs_is_null(payload))
|
||||||
args = xs_json_loads(payload);
|
args = xs_json_loads(payload);
|
||||||
|
@ -3235,6 +3247,9 @@ int mastoapi_patch_handler(const xs_dict *req, const char *q_path,
|
||||||
xs *args = NULL;
|
xs *args = NULL;
|
||||||
const char *i_ctype = xs_dict_get(req, "content-type");
|
const char *i_ctype = xs_dict_get(req, "content-type");
|
||||||
|
|
||||||
|
if (i_ctype == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (i_ctype && xs_startswith(i_ctype, "application/json")) {
|
if (i_ctype && xs_startswith(i_ctype, "application/json")) {
|
||||||
if (!xs_is_null(payload))
|
if (!xs_is_null(payload))
|
||||||
args = xs_json_loads(payload);
|
args = xs_json_loads(payload);
|
||||||
|
|
Loading…
Reference in a new issue