Change all instances of "URI" to "URL" because that's more sensible
authorArt Cancro <ajc@citadel.org>
Fri, 10 Dec 2021 23:22:28 +0000 (18:22 -0500)
committerArt Cancro <ajc@citadel.org>
Fri, 10 Dec 2021 23:22:28 +0000 (18:22 -0500)
webcit-ng/README.txt
webcit-ng/admin_functions.c
webcit-ng/api.txt
webcit-ng/ctdl_commands.c
webcit-ng/http.c
webcit-ng/request.c
webcit-ng/room_functions.c
webcit-ng/static.c
webcit-ng/user_functions.c
webcit-ng/webcit.h

index 435df81a1bd315b1d6ebdbfa8bce48c07b084aa9..3d8f60355987f48336be2b4b93492cc4a5eac352 100644 (file)
@@ -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]
 
index 9ac3d1a1860ea516941846a9c421ef8c03e58c71..c303ac4d47bd80288cf33197f81deb2ff916ecaa 100644 (file)
@@ -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;
        }
index 635feb3ead400ecfafd97d4c5f18baece61db8be..64da3c2de92285283c74ab13d1c680a5badf5f0f 100644 (file)
@@ -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
index 90c10e17cad92ba493b7a2d74a58768688c86e94..f1a2e2bec1c42007d91a6ad2a86ce970e2476515 100644 (file)
@@ -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 {
index a79473e79f7b8039fd05c092f2ed1f274e6de99e..b1ee0abd945ea887475154c8c7a9cd0e444dafc9 100644 (file)
@@ -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)
index 9f6966b2387db55a0561ae4ed9c9a0ae1389df34..294bcb6527589d18545ccea10b5793ef6e823bec 100644 (file)
@@ -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"));
index 6e081bd298a39248404323cb7a68c8764b74c2b2..8e00e7ecd413e482f263f641106029c55204e9cd 100644 (file)
@@ -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;
        }
index 80f506431e1a68b2ede0cf3894cf9c0bdd8ee159..f2b7811e0fd5a61ad614ca8af6d5fd3d8b5adb99 100644 (file)
@@ -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.
index fbecef57c75802b3c09ecf0eb7b3653fb2308a7a..925f3b4c9b6aceafdc0cc644e267d3345100a0c1 100644 (file)
@@ -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;
        }
index 6a781b1c22c36a40d259a1f9506ff0314d367fd5..70097b748d8f3a12b416437cb3614c7829d426af 100644 (file)
@@ -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;