From: Art Cancro Date: Fri, 10 Dec 2021 23:22:28 +0000 (-0500) Subject: Change all instances of "URI" to "URL" because that's more sensible X-Git-Tag: v943~42 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=05137ad46ee7304defa152b5cfe23bed4fe16d0c;p=citadel.git Change all instances of "URI" to "URL" because that's more sensible --- diff --git a/webcit-ng/README.txt b/webcit-ng/README.txt index 435df81a1..3d8f60355 100644 --- a/webcit-ng/README.txt +++ b/webcit-ng/README.txt @@ -25,7 +25,7 @@ DESIGN GOALS: -REST format URIs will generally take the form of: +REST format URLs will generally take the form of: /ctdl/objectClass/[container/]object[/operation] diff --git a/webcit-ng/admin_functions.c b/webcit-ng/admin_functions.c index 9ac3d1a18..c303ac4d4 100644 --- a/webcit-ng/admin_functions.c +++ b/webcit-ng/admin_functions.c @@ -77,17 +77,17 @@ void whoami(struct http_transaction *h, struct ctdlsession *c) { // Dispatcher for paths starting with /ctdl/a/ void ctdl_a(struct http_transaction *h, struct ctdlsession *c) { - if (!strcasecmp(h->uri, "/ctdl/a/login")) { // log in + if (!strcasecmp(h->url, "/ctdl/a/login")) { // log in try_login(h, c); return; } - if (!strcasecmp(h->uri, "/ctdl/a/logout")) { // log out + if (!strcasecmp(h->url, "/ctdl/a/logout")) { // log out logout(h, c); return; } - if (!strcasecmp(h->uri, "/ctdl/a/whoami")) { // return display name of user + if (!strcasecmp(h->url, "/ctdl/a/whoami")) { // return display name of user whoami(h, c); return; } diff --git a/webcit-ng/api.txt b/webcit-ng/api.txt index 635feb3ea..64da3c2de 100644 --- a/webcit-ng/api.txt +++ b/webcit-ng/api.txt @@ -1,5 +1,5 @@ -Method URI Function +Method URL Function ------ ------------------------------ ------------------------------------- GET /ctdl/a/landing.html Site root redirects to here GET /ctdl/r/ returns a JSON-encoded list of accessible rooms diff --git a/webcit-ng/ctdl_commands.c b/webcit-ng/ctdl_commands.c index 90c10e17c..f1a2e2bec 100644 --- a/webcit-ng/ctdl_commands.c +++ b/webcit-ng/ctdl_commands.c @@ -92,7 +92,7 @@ void serv_info(struct http_transaction *h, struct ctdlsession *c) { // Dispatcher for paths starting with /ctdl/c/ void ctdl_c(struct http_transaction *h, struct ctdlsession *c) { - if (!strcasecmp(h->uri, "/ctdl/c/info")) { + if (!strcasecmp(h->url, "/ctdl/c/info")) { serv_info(h, c); } else { diff --git a/webcit-ng/http.c b/webcit-ng/http.c index a79473e79..b1ee0abd9 100644 --- a/webcit-ng/http.c +++ b/webcit-ng/http.c @@ -118,11 +118,11 @@ void perform_one_http_transaction(struct client_handle *ch) { while (len = client_readline(ch, buf, sizeof buf), (len > 0)) { ++lines_read; - if (lines_read == 1) { // First line is method and URI. + if (lines_read == 1) { // First line is method and URL. c = strchr(buf, ' '); // IGnore the HTTP-version. if (c == NULL) { h.method = strdup("NULL"); - h.uri = strdup("/"); + h.url = strdup("/"); } else { *c = 0; @@ -134,7 +134,7 @@ void perform_one_http_transaction(struct client_handle *ch) { *c = 0; } ++c; - h.uri = strdup(d); + h.url = strdup(d); } } else { // Subsequent lines are headers. @@ -177,7 +177,7 @@ void perform_one_http_transaction(struct client_handle *ch) { syslog(LOG_DEBUG, "Client disconnected"); } else { - syslog(LOG_DEBUG, "\033[33m\033[1m< %s %s\033[0m", h.method, h.uri); + syslog(LOG_DEBUG, "\033[33m\033[1m< %s %s\033[0m", h.method, h.url); // If there is a request body, read it now. char *ccl = header_val(&h, "Content-Length"); @@ -246,8 +246,8 @@ void perform_one_http_transaction(struct client_handle *ch) { } if (h.method) free(h.method); - if (h.uri) - free(h.uri); + if (h.url) + free(h.url); if (h.request_body) free(h.request_body); if (h.response_string) diff --git a/webcit-ng/request.c b/webcit-ng/request.c index 9f6966b23..294bcb652 100644 --- a/webcit-ng/request.c +++ b/webcit-ng/request.c @@ -72,11 +72,11 @@ void http_redirect(struct http_transaction *h, char *to_where) { void perform_request(struct http_transaction *h) { struct ctdlsession *c; - // Determine which code path to take based on the beginning of the URI. + // Determine which code path to take based on the beginning of the URL. // This is implemented as a series of strncasecmp() calls rather than a // lookup table in order to make the code more readable. - if (IsEmptyStr(h->uri)) { // Sanity check + if (IsEmptyStr(h->url)) { // Sanity check do_404(h); return; } @@ -85,27 +85,27 @@ void perform_request(struct http_transaction *h) { // with the /ctdl/ prefix. // Root (/) ... - if ((!strcmp(h->uri, "/")) && (!strcasecmp(h->method, "GET"))) { + if ((!strcmp(h->url, "/")) && (!strcasecmp(h->method, "GET"))) { http_redirect(h, "/ctdl/s/index.html"); return; } - // Legacy URI patterns (/readnew?gotoroom=xxx&start_reading_at=yyy) ... + // Legacy URL patterns (/readnew?gotoroom=xxx&start_reading_at=yyy) ... // Direct room name (/my%20blog) ... - // Everything below this line is strictly REST URI patterns. + // Everything below this line is strictly REST URL patterns. - if (strncasecmp(h->uri, HKEY("/ctdl/"))) { // Reject non-REST + if (strncasecmp(h->url, HKEY("/ctdl/"))) { // Reject non-REST do_404(h); return; } - if (!strncasecmp(h->uri, HKEY("/ctdl/s/"))) { // Static content + if (!strncasecmp(h->url, HKEY("/ctdl/s/"))) { // Static content output_static(h); return; } - if (h->uri[7] != '/') { + if (h->url[7] != '/') { do_404(h); return; } @@ -134,8 +134,8 @@ void perform_request(struct http_transaction *h) { } } - // Break down the URI by path and send the request to the appropriate part of the program. - switch (h->uri[6]) { + // Break down the URL by path and send the request to the appropriate part of the program. + switch (h->url[6]) { case 'a': // /ctdl/a/ == RESTful path to admin functions ctdl_a(h, c); break; @@ -161,7 +161,7 @@ void perform_request(struct http_transaction *h) { add_response_header(h, strdup("Set-Cookie"), strdup(koekje)); } - // During development we are foiling the browser cache completely. In production we'll be more selective. + // Durlng development we are foiling the browser cache completely. In production we'll be more selective. add_response_header(h, strdup("Cache-Control"), strdup("no-store, must-revalidate")); add_response_header(h, strdup("Pragma"), strdup("no-cache")); add_response_header(h, strdup("Expires"), strdup("0")); diff --git a/webcit-ng/room_functions.c b/webcit-ng/room_functions.c index 6e081bd29..8e00e7ecd 100644 --- a/webcit-ng/room_functions.c +++ b/webcit-ng/room_functions.c @@ -112,7 +112,7 @@ void object_in_room(struct http_transaction *h, struct ctdlsession *c) { long msgnum = (-1); char unescaped_euid[1024]; - extract_token(buf, h->uri, 4, '/', sizeof buf); + extract_token(buf, h->url, 4, '/', sizeof buf); if (!strncasecmp(buf, "msgs.", 5)) { // Client is requesting a list of message numbers unescape_input(&buf[5]); @@ -154,8 +154,8 @@ void object_in_room(struct http_transaction *h, struct ctdlsession *c) { // A sixth component in the URL can be one of two things: // (1) a MIME part specifier, in which case the client wants to download that component within the message // (2) a content-type, in which ase the client wants us to try to render it a certain way - if (num_tokens(h->uri, '/') == 6) { - extract_token(buf, h->uri, 5, '/', sizeof buf); + if (num_tokens(h->url, '/') == 6) { + extract_token(buf, h->url, 5, '/', sizeof buf); if (!IsEmptyStr(buf)) { if (!strcasecmp(buf, "json")) { json_render_one_message(h, c, msgnum); @@ -494,7 +494,7 @@ void ctdl_r(struct http_transaction *h, struct ctdlsession *c) { char buf[1024]; // All room-related functions require being "in" the room specified. Are we in that room already? - extract_token(requested_roomname, h->uri, 3, '/', sizeof requested_roomname); + extract_token(requested_roomname, h->url, 3, '/', sizeof requested_roomname); unescape_input(requested_roomname); if (IsEmptyStr(requested_roomname)) { // /ctdl/r/ @@ -531,14 +531,14 @@ void ctdl_r(struct http_transaction *h, struct ctdlsession *c) { } // At this point our Citadel client session is "in" the specified room. - if (num_tokens(h->uri, '/') == 4) // /ctdl/r/roomname + if (num_tokens(h->url, '/') == 4) // /ctdl/r/roomname { the_room_itself(h, c); return; } - extract_token(buf, h->uri, 4, '/', sizeof buf); - if (num_tokens(h->uri, '/') == 5) { + extract_token(buf, h->url, 4, '/', sizeof buf); + if (num_tokens(h->url, '/') == 5) { if (IsEmptyStr(buf)) { the_room_itself(h, c); // /ctdl/r/roomname/ ( same as /ctdl/r/roomname ) } @@ -547,7 +547,7 @@ void ctdl_r(struct http_transaction *h, struct ctdlsession *c) { } return; } - if (num_tokens(h->uri, '/') == 6) { + if (num_tokens(h->url, '/') == 6) { object_in_room(h, c); // /ctdl/r/roomname/object/ or possibly /ctdl/r/roomname/object/component return; } diff --git a/webcit-ng/static.c b/webcit-ng/static.c index 80f506431..f2b7811e0 100644 --- a/webcit-ng/static.c +++ b/webcit-ng/static.c @@ -21,7 +21,7 @@ void output_static(struct http_transaction *h) { char filename[PATH_MAX]; struct stat statbuf; - snprintf(filename, sizeof filename, "static/%s", &h->uri[8]); + snprintf(filename, sizeof filename, "static/%s", &h->url[8]); if (strstr(filename, "../")) { // 100% guaranteed attacker. do_404(h); // Die in a car fire. diff --git a/webcit-ng/user_functions.c b/webcit-ng/user_functions.c index fbecef57c..925f3b4c9 100644 --- a/webcit-ng/user_functions.c +++ b/webcit-ng/user_functions.c @@ -59,7 +59,7 @@ void fetch_user_bio(struct http_transaction *h, struct ctdlsession *c, char *use void object_in_user(struct http_transaction *h, struct ctdlsession *c, char *requested_username) { char object_name[1024]; - extract_token(object_name, h->uri, 4, '/', sizeof object_name); + extract_token(object_name, h->url, 4, '/', sizeof object_name); if (!strcasecmp(object_name, "userpic")) { // user photo (avatar) fetch_user_photo(h, c, requested_username); @@ -95,7 +95,7 @@ void ctdl_u(struct http_transaction *h, struct ctdlsession *c) { char buf[1024]; // All user-related functions require accessing the user in question. - extract_token(requested_username, h->uri, 3, '/', sizeof requested_username); + extract_token(requested_username, h->url, 3, '/', sizeof requested_username); unescape_input(requested_username); if (IsEmptyStr(requested_username)) { // /ctdl/u/ @@ -106,13 +106,13 @@ void ctdl_u(struct http_transaction *h, struct ctdlsession *c) { // At this point we have extracted the name of the user we're interested in. // FIXME should we validate it? - if (num_tokens(h->uri, '/') == 4) { // /ctdl/u/username + if (num_tokens(h->url, '/') == 4) { // /ctdl/u/username the_user_itself(h, c, requested_username); return; } - extract_token(buf, h->uri, 4, '/', sizeof buf); - if (num_tokens(h->uri, '/') == 5) { + extract_token(buf, h->url, 4, '/', sizeof buf); + if (num_tokens(h->url, '/') == 5) { if (IsEmptyStr(buf)) { the_user_itself(h, c, requested_username); // /ctdl/u/username/ ( same as /ctdl/u/username ) } @@ -122,7 +122,7 @@ void ctdl_u(struct http_transaction *h, struct ctdlsession *c) { return; } - if (num_tokens(h->uri, '/') == 6) { + if (num_tokens(h->url, '/') == 6) { object_in_user(h, c, requested_username); // /ctdl/u/username/object/ or possibly /ctdl/u/username/object/component return; } diff --git a/webcit-ng/webcit.h b/webcit-ng/webcit.h index 6a781b1c2..70097b748 100644 --- a/webcit-ng/webcit.h +++ b/webcit-ng/webcit.h @@ -60,7 +60,7 @@ struct http_header { // request and response headers in struct http_transacti struct http_transaction { // The lifetime of an HTTP request goes through this data structure. char *method; // The top half is built up by the web server and sent up to the - char *uri; // application stack. The second half is built up by the application + char *url; // application stack. The second half is built up by the application char *http_version; // stack and sent back down to the web server, which transmits it to char *site_prefix; // the client. struct http_header *request_headers;