diff options
| author | 2024-09-16 07:28:28 +0000 | |
|---|---|---|
| committer | 2024-09-16 07:28:28 +0000 | |
| commit | a09e5052ddd8df423332ada814e743893878e0b9 (patch) | |
| tree | 732e4a923354f64614991c46fe264b7e0e78ef1e | |
| parent | Version 2.59 RELEASED. (diff) | |
| parent | URL decode data after splitting the arguments (diff) | |
| download | snac2-a09e5052ddd8df423332ada814e743893878e0b9.tar.gz snac2-a09e5052ddd8df423332ada814e743893878e0b9.tar.xz snac2-a09e5052ddd8df423332ada814e743893878e0b9.zip | |
Merge pull request 'URL decode data after splitting the arguments' (#196) from ndagestad/snac2:mastodon_login into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/196
| -rw-r--r-- | mastoapi.c | 12 | ||||
| -rw-r--r-- | xs_fcgi.h | 6 | ||||
| -rw-r--r-- | xs_httpd.h | 5 | ||||
| -rw-r--r-- | xs_url.h | 2 |
4 files changed, 9 insertions, 16 deletions
| @@ -262,8 +262,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 262 | } | 262 | } |
| 263 | else | 263 | else |
| 264 | if (i_ctype && xs_startswith(i_ctype, "application/x-www-form-urlencoded") && payload) { | 264 | if (i_ctype && xs_startswith(i_ctype, "application/x-www-form-urlencoded") && payload) { |
| 265 | xs *upl = xs_url_dec(payload); | 265 | args = xs_url_vars(payload); |
| 266 | args = xs_url_vars(upl); | ||
| 267 | } | 266 | } |
| 268 | else | 267 | else |
| 269 | args = xs_dup(xs_dict_get(req, "p_vars")); | 268 | args = xs_dup(xs_dict_get(req, "p_vars")); |
| @@ -2361,8 +2360,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 2361 | { | 2360 | { |
| 2362 | // Some apps send form data instead of json so we should cater for those | 2361 | // Some apps send form data instead of json so we should cater for those |
| 2363 | if (!xs_is_null(payload)) { | 2362 | if (!xs_is_null(payload)) { |
| 2364 | xs *upl = xs_url_dec(payload); | 2363 | args = xs_url_vars(payload); |
| 2365 | args = xs_url_vars(upl); | ||
| 2366 | } | 2364 | } |
| 2367 | } | 2365 | } |
| 2368 | else | 2366 | else |
| @@ -2959,8 +2957,7 @@ int mastoapi_delete_handler(const xs_dict *req, const char *q_path, | |||
| 2959 | { | 2957 | { |
| 2960 | // Some apps send form data instead of json so we should cater for those | 2958 | // Some apps send form data instead of json so we should cater for those |
| 2961 | if (!xs_is_null(payload)) { | 2959 | if (!xs_is_null(payload)) { |
| 2962 | xs *upl = xs_url_dec(payload); | 2960 | args = xs_url_vars(payload); |
| 2963 | args = xs_url_vars(upl); | ||
| 2964 | } | 2961 | } |
| 2965 | } | 2962 | } |
| 2966 | else | 2963 | else |
| @@ -3194,8 +3191,7 @@ int mastoapi_patch_handler(const xs_dict *req, const char *q_path, | |||
| 3194 | { | 3191 | { |
| 3195 | // Some apps send form data instead of json so we should cater for those | 3192 | // Some apps send form data instead of json so we should cater for those |
| 3196 | if (!xs_is_null(payload)) { | 3193 | if (!xs_is_null(payload)) { |
| 3197 | xs *upl = xs_url_dec(payload); | 3194 | args = xs_url_vars(payload); |
| 3198 | args = xs_url_vars(upl); | ||
| 3199 | } | 3195 | } |
| 3200 | } | 3196 | } |
| 3201 | else | 3197 | else |
| @@ -179,8 +179,7 @@ xs_dict *xs_fcgi_request(FILE *f, xs_str **payload, int *p_size, int *fcgi_id) | |||
| 179 | req = xs_dict_append(req, "method", v); | 179 | req = xs_dict_append(req, "method", v); |
| 180 | else | 180 | else |
| 181 | if (strcmp(k, "REQUEST_URI") == 0) { | 181 | if (strcmp(k, "REQUEST_URI") == 0) { |
| 182 | xs *udp = xs_url_dec(v); | 182 | xs *pnv = xs_split_n(v, "?", 1); |
| 183 | xs *pnv = xs_split_n(udp, "?", 1); | ||
| 184 | 183 | ||
| 185 | /* store the path */ | 184 | /* store the path */ |
| 186 | req = xs_dict_append(req, "path", xs_list_get(pnv, 0)); | 185 | req = xs_dict_append(req, "path", xs_list_get(pnv, 0)); |
| @@ -233,8 +232,7 @@ xs_dict *xs_fcgi_request(FILE *f, xs_str **payload, int *p_size, int *fcgi_id) | |||
| 233 | const char *ct = xs_dict_get(req, "content-type"); | 232 | const char *ct = xs_dict_get(req, "content-type"); |
| 234 | 233 | ||
| 235 | if (*payload && ct && strcmp(ct, "application/x-www-form-urlencoded") == 0) { | 234 | if (*payload && ct && strcmp(ct, "application/x-www-form-urlencoded") == 0) { |
| 236 | xs *upl = xs_url_dec(*payload); | 235 | p_vars = xs_url_vars(*payload); |
| 237 | p_vars = xs_url_vars(upl); | ||
| 238 | } | 236 | } |
| 239 | else | 237 | else |
| 240 | if (*payload && ct && xs_startswith(ct, "multipart/form-data")) { | 238 | if (*payload && ct && xs_startswith(ct, "multipart/form-data")) { |
| @@ -36,7 +36,7 @@ xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size) | |||
| 36 | 36 | ||
| 37 | { | 37 | { |
| 38 | /* split the path with its optional variables */ | 38 | /* split the path with its optional variables */ |
| 39 | xs *udp = xs_url_dec(xs_list_get(l2, 1)); | 39 | const xs_val *udp = xs_list_get(l2, 1); |
| 40 | xs *pnv = xs_split_n(udp, "?", 1); | 40 | xs *pnv = xs_split_n(udp, "?", 1); |
| 41 | 41 | ||
| 42 | /* store the path */ | 42 | /* store the path */ |
| @@ -75,8 +75,7 @@ xs_dict *xs_httpd_request(FILE *f, xs_str **payload, int *p_size) | |||
| 75 | v = xs_dict_get(req, "content-type"); | 75 | v = xs_dict_get(req, "content-type"); |
| 76 | 76 | ||
| 77 | if (*payload && v && strcmp(v, "application/x-www-form-urlencoded") == 0) { | 77 | if (*payload && v && strcmp(v, "application/x-www-form-urlencoded") == 0) { |
| 78 | xs *upl = xs_url_dec(*payload); | 78 | p_vars = xs_url_vars(*payload); |
| 79 | p_vars = xs_url_vars(upl); | ||
| 80 | } | 79 | } |
| 81 | else | 80 | else |
| 82 | if (*payload && v && xs_startswith(v, "multipart/form-data")) { | 81 | if (*payload && v && xs_startswith(v, "multipart/form-data")) { |
| @@ -53,7 +53,7 @@ xs_dict *xs_url_vars(const char *str) | |||
| 53 | const xs_val *v; | 53 | const xs_val *v; |
| 54 | 54 | ||
| 55 | xs_list_foreach(args, v) { | 55 | xs_list_foreach(args, v) { |
| 56 | xs *kv = xs_split_n(v, "=", 1); | 56 | xs *kv = xs_split_n(xs_url_dec(v), "=", 1); |
| 57 | 57 | ||
| 58 | if (xs_list_len(kv) == 2) { | 58 | if (xs_list_len(kv) == 2) { |
| 59 | const char *key = xs_list_get(kv, 0); | 59 | const char *key = xs_list_get(kv, 0); |