diff --git a/1998/dlowe/.gitignore b/1998/dlowe/.gitignore index 929663f8b..5855a6a26 100644 --- a/1998/dlowe/.gitignore +++ b/1998/dlowe/.gitignore @@ -3,3 +3,4 @@ dlowe.alt README.poot.md dlowe.orig prog.orig +make.1 diff --git a/1998/dlowe/README.md b/1998/dlowe/README.md index a385f3d48..d77e5c351 100644 --- a/1998/dlowe/README.md +++ b/1998/dlowe/README.md @@ -33,6 +33,12 @@ For more detailed information see [1998 dlowe in bugs.md](/bugs.md#1998-dlowe). Why is there different output? +Also try: + +```sh +./try.sh +``` + ## Alternate code: @@ -58,8 +64,10 @@ a CGI program: ms.html +``` + +where the first one would show the text as rendered but without links, images +etc. and the second one would write the html to ms.html so that you could open +it in a browser. + +If one does use it as a CGI script you'll want to check out +[pootify.cgi.sh](pootify.cgi.sh) which forbids `file://` based URLs and which +uses `lynx(1)` with the option referred to above. + +For an old example of it working as a CGI script see: ```sh https://web.archive.org/web/20040326083431/http://www.pootpoot.com/poot/pootify/?URL=http%3A%2F%2Fwww.ioccc.org @@ -96,8 +130,8 @@ https://web.archive.org/web/20040326083431/http://www.pootpoot.com/poot/pootify/ ## Author's remarks: -This program is a text filter, it reads stdin and outputs the -"corrected" text to stdout. +This program is a text filter, it reads `stdin` and outputs the +"corrected" text to `stdout`. It is obfuscated in that the code is painful to look at and its purpose and mode of operation are not terribly obvious. diff --git a/1998/dlowe/pootify.cgi.sh b/1998/dlowe/pootify.cgi.sh new file mode 100755 index 000000000..e7649aa70 --- /dev/null +++ b/1998/dlowe/pootify.cgi.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# +# pootify.cgi.sh - a sample CGI pootifier +# +POOT="./dlowe" +LYNX="lynx" +ECHO="echo" +EXPR="expr" + +${ECHO} "Content-type: text/html" +${ECHO} + +QUERY_STRING="$1" +if [[ -z "${QUERY_STRING}" ]]; then + ${ECHO} "QUERY_STRING not found" +else + URL="$(${EXPR} "$QUERY_STRING" : '[Uu][Rr][Ll]=\(.*\)')" + if [[ -z "${URL}" ]]; then + ${ECHO} "No URL given in QUERY_STRING" + elif [[ X"$(${EXPR} "${URL}" : '[Ff][Ii][Ll][Ee]:')" != X0 ]]; then + ${ECHO} "file: based URLs are not allowed" + else + ${LYNX} -restrictions=all -source "${URL}" | ${POOT} + fi +fi diff --git a/1998/dlowe/pootify.sh b/1998/dlowe/pootify.sh new file mode 100755 index 000000000..e9b8204a2 --- /dev/null +++ b/1998/dlowe/pootify.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# +# Script to download a page and pootify it. You can pipe it through less(1) to +# see the output or you can redirect it to a file and open it in your local +# browser (use the -r option for that). +# +# Note from 2023: this used to be a CGI script that used lynx(1) which has +# security features but lynx does not work with redirects, it would appear, and +# unfortunately links(1) does not have such restrictions. If you wanted to use +# it anyway you could change the -dump to -source and see how it goes. It might +# also be that if it was used as a CGI script it would work well but this has +# not been tested. +# +# Example uses: +# +# ./pootify.sh URL=https://microsoft.com | less +# +# ./pootify.sh -r URL=https://microsoft.com > ms.html +# +# and then open ms.html in your local browser. Neither are as nice as a rendered +# html page as a script from another page and certainly it's less convenient but +# you can at least enjoy the output somewhat, the latter one more so, perhaps. +# +POOT="./dlowe" +LINKS="links" +ECHO="echo" +EXPR="expr" +RAW="" +${ECHO} "Content-type: text/html" +${ECHO} +if [[ "$#" -eq 2 ]]; then + if [[ "$1" = "-r" ]]; then + RAW="-r" + fi + shift 1 +fi + +QUERY_STRING="$1" +if [[ -z "${QUERY_STRING}" ]]; then + ${ECHO} "QUERY_STRING not found" +else + URL="$(${EXPR} "$QUERY_STRING" : '[Uu][Rr][Ll]=\(.*\)')" + if [[ -z "${URL}" ]]; then + ${ECHO} "No URL given in QUERY_STRING" + # if used as a CGI script uncomment the below: + #elif [[ X"$(${EXPR} "${URL}" : '[Ff][Ii][Ll][Ee]:')" != X0 ]]; then + # ${ECHO} "file: based URLs are not allowed" + elif [[ -n "$RAW" ]]; then + ${LINKS} -source "${URL}" | ${POOT} + else + ${LINKS} -dump "${URL}" | ${POOT} + fi +fi diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 055f0e328..46271cc2a 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -2048,6 +2048,17 @@ Cody added a call to `endwin()` to restore terminal sanity (echo etc.) when exiting the program. +## [1998/dlowe](1998/dlowe/dlowe.c) ([README.md](1998/dlowe/README.md])) + +Cody added the scripts [try.sh](1998/dlowe/try.sh), +[pootify.sh](1998/dlowe/pootify.sh) and +[pootify.cgi.sh](1998/dlowe/pootify.cgi.sh) for a fun example use of the +program, a local pootifier of web pages and a CGI pootifier. It should be noted +that the CGI version might have an issue with modern systems; see [historical +remarks](1998/dlowe/README.md#historical-remarks) for more details on the +pootify scripts. + + ## [1998/dloweneil](1998/dloweneil/dloweneil.c) ([README.md](1998/dloweneil/README.md])) Cody added [alt code](1998/dloweneil/dloweneil.alt.c) which has vi(m) movement