summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorGravatar default2024-06-01 08:47:50 +0200
committerGravatar default2024-06-01 08:47:50 +0200
commit7a6b94a058dcef6f94eb98e404f56f2872ece3c5 (patch)
tree2983290b17767b0bc23548caa7b00969721d55c3 /mastoapi.c
parentAvoid unnecessary calls to verify links. (diff)
downloadsnac2-7a6b94a058dcef6f94eb98e404f56f2872ece3c5.tar.gz
snac2-7a6b94a058dcef6f94eb98e404f56f2872ece3c5.tar.xz
snac2-7a6b94a058dcef6f94eb98e404f56f2872ece3c5.zip
mastoapi: fix crashes on unset content-type.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 6c2c38c..a129ad0 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -243,6 +243,9 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
243 const char *i_ctype = xs_dict_get(req, "content-type"); 243 const char *i_ctype = xs_dict_get(req, "content-type");
244 xs *args = NULL; 244 xs *args = NULL;
245 245
246 if (i_ctype == NULL)
247 return 0;
248
246 if (i_ctype && xs_startswith(i_ctype, "application/json")) { 249 if (i_ctype && xs_startswith(i_ctype, "application/json")) {
247 if (!xs_is_null(payload)) 250 if (!xs_is_null(payload))
248 args = xs_json_loads(payload); 251 args = xs_json_loads(payload);
@@ -2412,6 +2415,9 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
2412 xs *args = NULL; 2415 xs *args = NULL;
2413 const char *i_ctype = xs_dict_get(req, "content-type"); 2416 const char *i_ctype = xs_dict_get(req, "content-type");
2414 2417
2418 if (i_ctype == NULL)
2419 return 0;
2420
2415 if (i_ctype && xs_startswith(i_ctype, "application/json")) { 2421 if (i_ctype && xs_startswith(i_ctype, "application/json")) {
2416 if (!xs_is_null(payload)) 2422 if (!xs_is_null(payload))
2417 args = xs_json_loads(payload); 2423 args = xs_json_loads(payload);
@@ -3000,6 +3006,9 @@ int mastoapi_delete_handler(const xs_dict *req, const char *q_path,
3000 xs *args = NULL; 3006 xs *args = NULL;
3001 const char *i_ctype = xs_dict_get(req, "content-type"); 3007 const char *i_ctype = xs_dict_get(req, "content-type");
3002 3008
3009 if (i_ctype == NULL)
3010 return 0;
3011
3003 if (i_ctype && xs_startswith(i_ctype, "application/json")) { 3012 if (i_ctype && xs_startswith(i_ctype, "application/json")) {
3004 if (!xs_is_null(payload)) 3013 if (!xs_is_null(payload))
3005 args = xs_json_loads(payload); 3014 args = xs_json_loads(payload);
@@ -3088,6 +3097,9 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path,
3088 xs *args = NULL; 3097 xs *args = NULL;
3089 const char *i_ctype = xs_dict_get(req, "content-type"); 3098 const char *i_ctype = xs_dict_get(req, "content-type");
3090 3099
3100 if (i_ctype == NULL)
3101 return 0;
3102
3091 if (i_ctype && xs_startswith(i_ctype, "application/json")) { 3103 if (i_ctype && xs_startswith(i_ctype, "application/json")) {
3092 if (!xs_is_null(payload)) 3104 if (!xs_is_null(payload))
3093 args = xs_json_loads(payload); 3105 args = xs_json_loads(payload);
@@ -3235,6 +3247,9 @@ int mastoapi_patch_handler(const xs_dict *req, const char *q_path,
3235 xs *args = NULL; 3247 xs *args = NULL;
3236 const char *i_ctype = xs_dict_get(req, "content-type"); 3248 const char *i_ctype = xs_dict_get(req, "content-type");
3237 3249
3250 if (i_ctype == NULL)
3251 return 0;
3252
3238 if (i_ctype && xs_startswith(i_ctype, "application/json")) { 3253 if (i_ctype && xs_startswith(i_ctype, "application/json")) {
3239 if (!xs_is_null(payload)) 3254 if (!xs_is_null(payload))
3240 args = xs_json_loads(payload); 3255 args = xs_json_loads(payload);