From b0547ba9f48bf402665b89f84b88b80ee58d8824 Mon Sep 17 00:00:00 2001 From: bptato Date: Mon, 8 Jan 2024 00:37:54 +0100 Subject: Add urlenc, urldec; fix a URL encoding bug; improve trans.cgi * Fix incorrect internal definition of the fragment percent-encode set * urlenc, urldec: these are simple utility programs mainly for use with shell local CGI scripts. (Sadly the printf + xargs solution is not portable.) * Pass libexec directory as an env var to local CGI scripts * Update trans.cgi to use urldec and add an example for combining it with selections --- doc/localcgi.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'doc') diff --git a/doc/localcgi.md b/doc/localcgi.md index 2d15e6af..206a3ef7 100644 --- a/doc/localcgi.md +++ b/doc/localcgi.md @@ -118,6 +118,9 @@ Chawan sets the following environment variables: * `REQUEST_URI="$SCRIPT_NAME/$PATH_INFO?$QUERY_STRING` * `REQUEST_METHOD=` HTTP method used for making the request, e.g. GET or POST * `REQUEST_HEADERS=` A newline-separated list of all headers for this request. +* `CHA_LIBEXEC_DIR=` The libexec directory Chawan was configured to use at + compile time. See the [tools](#tools) section below for details of + why this is useful. * `CONTENT_TYPE=` for POST requests, the Content-Type header. Not set for other request types (e.g. GET). * `CONTENT_LENGTH=` the content length, if $CONTENT_TYPE has been set. @@ -165,6 +168,18 @@ Note that this may be both an application/x-www-form-urlencoded or a multipart/form-data request; `CONTENT_TYPE` stores information about the request type, and in case of a multipart request, the boundary as well. +## Tools + +Chawan provides certain helper binaries that may be useful for CGI +scripts. These can be portably accessed by executing +`"$CHA_LIBEXEC_DIR"/[program name]`. + +Currently, the following tools are available: + +* `urldec`: percent-decode strings passed on standard input. +* `urlenc`: percent-encode strings passed on standard input, taking a + percent-encode set as the first parameter. + ## Troubleshooting Note that standard error is redirected to the browser console (by default, -- cgit 1.4.1-2-gfad0