geomyidae

A small C-based gopherd. (gopher://bitreich.org/1/scm/geomyidae)
git clone git://r-36.net/geomyidae
Log | Files | Refs | README | LICENSE

commit 06a070824c9fcbc590986c1931ca6266463a613f
parent c5d96276bca47a0598ba696e8787a437a1ba6344
Author: Christopher Williams <abbrev@gmail.com>
Date:   Mon,  5 May 2025 16:32:51 -0700

Fix CGI environment variables

Rename:

* PATH_INFO to SCRIPT_NAME,
* PATH_TRANSLATED to SCRIPT_FILENAME, and
* TRAVERSAL to PATH_INFO

to conform with the CGI/1.1 spec (RFC 3875).

Signed-off-by: Christoph Lohmann <20h@r-36.net>

Diffstat:
Mgeomyidae.8 | 10++++------
Mind.c | 7+++----
2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/geomyidae.8 b/geomyidae.8 @@ -501,23 +501,21 @@ Additionally to the above arguments several environment variables are set. .It Ev GATEWAY_INTERFACE .Qq Cm CGI/1.1 .It Ev PATH_INFO -Script which is executed -.It Ev PATH_TRANSLATED -Absolute path with script which is executed +Traversal (See above.) .It Ev QUERY_STRING Arguments (See above.) .It Ev SELECTOR Raw selector .It Ev REQUEST Raw selector -.It Ev TRAVERSAL -Traversal (See above.) .It Ev REMOTE_ADDR , REMOTE_HOST IP of the client .It Ev REQUEST_METHOD .Qq Cm GET .It Ev SCRIPT_NAME Script which is executed. +.It Ev SCRIPT_FILENAME +Absolute path with script which is executed. .It Ev SERVER_NAME Server's hostname. .It Ev SERVER_PORT @@ -549,7 +547,7 @@ tries to find some index.dcgi or index.cgi file in the last existing directory. If this is found and the index files are executable, .Nm will execute them using the traversal and -.Ev TRAVERSAL +.Ev PATH_INFO parameter and environment variable being set to the rest path. .Bd -literal -offset indent Selector: /some/v1/service/add/something?args=value diff --git a/ind.c b/ind.c @@ -548,13 +548,13 @@ setcgienviron(char *file, char *path, char *port, char *base, char *args, unsetenv("CONTENT_TYPE"); setenv("GATEWAY_INTERFACE", "CGI/1.1", 1); /* TODO: Separate, if run like rest.dcgi. */ - setenv("PATH_INFO", path+strlen(base), 1); - setenv("PATH_TRANSLATED", path, 1); + setenv("SCRIPT_NAME", path+strlen(base), 1); + setenv("SCRIPT_FILENAME", path, 1); setenv("QUERY_STRING", args, 1); setenv("SELECTOR", sel, 1); setenv("REQUEST", sel, 1); - setenv("TRAVERSAL", traverse, 1); + setenv("PATH_INFO", traverse, 1); setenv("REMOTE_ADDR", chost, 1); /* @@ -572,7 +572,6 @@ setcgienviron(char *file, char *path, char *port, char *base, char *args, * ugly. */ setenv("REQUEST_METHOD", "GET", 1); - setenv("SCRIPT_NAME", file, 1); setenv("SERVER_NAME", ohost, 1); setenv("SERVER_PORT", port, 1); setenv("SERVER_LISTEN_NAME", bhost, 1);