summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--http.c2
-rw-r--r--mastoapi.c14
-rw-r--r--webfinger.c6
3 files changed, 11 insertions, 11 deletions
diff --git a/http.c b/http.c
index ae46001..58d188c 100644
--- a/http.c
+++ b/http.c
@@ -33,7 +33,7 @@ xs_dict *http_signed_request_raw(const char *keyid, const char *seckey,
33 date = xs_str_utctime(0, "%a, %d %b %Y %H:%M:%S GMT"); 33 date = xs_str_utctime(0, "%a, %d %b %Y %H:%M:%S GMT");
34 34
35 { 35 {
36 xs *s = xs_replace(url, "https:/" "/", ""); 36 xs *s = xs_replace_n(url, "https:/" "/", "", 1);
37 l1 = xs_split_n(s, "/", 1); 37 l1 = xs_split_n(s, "/", 1);
38 } 38 }
39 39
diff --git a/mastoapi.c b/mastoapi.c
index 72d9579..f7e101d 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -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);
diff --git a/webfinger.c b/webfinger.c
index eb6b2ad..f56b6f2 100644
--- a/webfinger.c
+++ b/webfinger.c
@@ -21,7 +21,7 @@ int webfinger_request(const char *qs, char **actor, char **user)
21 21
22 if (xs_startswith(qs, "https:/" "/")) { 22 if (xs_startswith(qs, "https:/" "/")) {
23 /* actor query: pick the host */ 23 /* actor query: pick the host */
24 xs *s = xs_replace(qs, "https:/" "/", ""); 24 xs *s = xs_replace_n(qs, "https:/" "/", "", 1);
25 25
26 l = xs_split_n(s, "/", 1); 26 l = xs_split_n(s, "/", 1);
27 27
@@ -74,7 +74,7 @@ int webfinger_request(const char *qs, char **actor, char **user)
74 char *subject = xs_dict_get(obj, "subject"); 74 char *subject = xs_dict_get(obj, "subject");
75 75
76 if (subject) 76 if (subject)
77 *user = xs_replace(subject, "acct:", ""); 77 *user = xs_replace_n(subject, "acct:", "", 1);
78 } 78 }
79 79
80 if (actor != NULL) { 80 if (actor != NULL) {
@@ -136,7 +136,7 @@ int webfinger_get_handler(d_char *req, char *q_path,
136 else 136 else
137 if (xs_startswith(resource, "acct:")) { 137 if (xs_startswith(resource, "acct:")) {
138 /* it's an account name */ 138 /* it's an account name */
139 xs *an = xs_replace(resource, "acct:", ""); 139 xs *an = xs_replace_n(resource, "acct:", "", 1);
140 xs *l = NULL; 140 xs *l = NULL;
141 141
142 /* strip a possible leading @ */ 142 /* strip a possible leading @ */