diff options
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 14 |
1 files changed, 7 insertions, 7 deletions
| @@ -185,7 +185,7 @@ int oauth_get_handler(const xs_dict *req, const char *q_path, | |||
| 185 | 185 | ||
| 186 | int status = 404; | 186 | int status = 404; |
| 187 | xs_dict *msg = xs_dict_get(req, "q_vars"); | 187 | xs_dict *msg = xs_dict_get(req, "q_vars"); |
| 188 | xs *cmd = xs_replace(q_path, "/oauth", ""); | 188 | xs *cmd = xs_replace_n(q_path, "/oauth", "", 1); |
| 189 | 189 | ||
| 190 | srv_debug(1, xs_fmt("oauth_get_handler %s", q_path)); | 190 | srv_debug(1, xs_fmt("oauth_get_handler %s", q_path)); |
| 191 | 191 | ||
| @@ -245,7 +245,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 245 | else | 245 | else |
| 246 | args = xs_dup(xs_dict_get(req, "p_vars")); | 246 | args = xs_dup(xs_dict_get(req, "p_vars")); |
| 247 | 247 | ||
| 248 | xs *cmd = xs_replace(q_path, "/oauth", ""); | 248 | xs *cmd = xs_replace_n(q_path, "/oauth", "", 1); |
| 249 | 249 | ||
| 250 | srv_debug(1, xs_fmt("oauth_post_handler %s", q_path)); | 250 | srv_debug(1, xs_fmt("oauth_post_handler %s", q_path)); |
| 251 | 251 | ||
| @@ -328,7 +328,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path, | |||
| 328 | const char *auhdr = xs_dict_get(req, "authorization"); | 328 | const char *auhdr = xs_dict_get(req, "authorization"); |
| 329 | 329 | ||
| 330 | if (!xs_is_null(auhdr) && xs_startswith(auhdr, "Basic ")) { | 330 | if (!xs_is_null(auhdr) && xs_startswith(auhdr, "Basic ")) { |
| 331 | xs *s1 = xs_replace(auhdr, "Basic ", ""); | 331 | xs *s1 = xs_replace_n(auhdr, "Basic ", "", 1); |
| 332 | int size; | 332 | int size; |
| 333 | xs *s2 = xs_base64_dec(s1, &size); | 333 | xs *s2 = xs_base64_dec(s1, &size); |
| 334 | 334 | ||
| @@ -787,7 +787,7 @@ int process_auth_token(snac *snac, const xs_dict *req) | |||
| 787 | 787 | ||
| 788 | /* if there is an authorization field, try to validate it */ | 788 | /* if there is an authorization field, try to validate it */ |
| 789 | if (!xs_is_null(v = xs_dict_get(req, "authorization")) && xs_startswith(v, "Bearer ")) { | 789 | if (!xs_is_null(v = xs_dict_get(req, "authorization")) && xs_startswith(v, "Bearer ")) { |
| 790 | xs *tokid = xs_replace(v, "Bearer ", ""); | 790 | xs *tokid = xs_replace_n(v, "Bearer ", "", 1); |
| 791 | xs *token = token_get(tokid); | 791 | xs *token = token_get(tokid); |
| 792 | 792 | ||
| 793 | if (token != NULL) { | 793 | if (token != NULL) { |
| @@ -826,7 +826,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 826 | 826 | ||
| 827 | int status = 404; | 827 | int status = 404; |
| 828 | xs_dict *args = xs_dict_get(req, "q_vars"); | 828 | xs_dict *args = xs_dict_get(req, "q_vars"); |
| 829 | xs *cmd = xs_replace(q_path, "/api", ""); | 829 | xs *cmd = xs_replace_n(q_path, "/api", "", 1); |
| 830 | 830 | ||
| 831 | snac snac1 = {0}; | 831 | snac snac1 = {0}; |
| 832 | int logged_in = process_auth_token(&snac1, req); | 832 | int logged_in = process_auth_token(&snac1, req); |
| @@ -1500,7 +1500,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 1500 | printf("%s\n", j); | 1500 | printf("%s\n", j); |
| 1501 | }*/ | 1501 | }*/ |
| 1502 | 1502 | ||
| 1503 | xs *cmd = xs_replace(q_path, "/api", ""); | 1503 | xs *cmd = xs_replace_n(q_path, "/api", "", 1); |
| 1504 | 1504 | ||
| 1505 | snac snac = {0}; | 1505 | snac snac = {0}; |
| 1506 | int logged_in = process_auth_token(&snac, req); | 1506 | int logged_in = process_auth_token(&snac, req); |
| @@ -1916,7 +1916,7 @@ int mastoapi_put_handler(const xs_dict *req, const char *q_path, | |||
| 1916 | if (args == NULL) | 1916 | if (args == NULL) |
| 1917 | return 400; | 1917 | return 400; |
| 1918 | 1918 | ||
| 1919 | xs *cmd = xs_replace(q_path, "/api", ""); | 1919 | xs *cmd = xs_replace_n(q_path, "/api", "", 1); |
| 1920 | 1920 | ||
| 1921 | snac snac = {0}; | 1921 | snac snac = {0}; |
| 1922 | int logged_in = process_auth_token(&snac, req); | 1922 | int logged_in = process_auth_token(&snac, req); |