Update 1998/dlowe - add scripts + formatting

The following scripts were added:

- try.sh: a fun use of the program.
- pootify.sh: a local pootifier that downloads a web page (or use a
local file) and either changes it to text or writes html which can be
viewed in a local browser.
- pootify.cgi.sh: a CGI version that the judges added but made to use
bash(1) and pass shellcheck(1). There is an issue that is known with
this and the 'Historical remarks' discusses this in more detail as well
as how to use the pootify.sh and pootify.cgi.sh scripts.

The README.md file has been formatted as well.
This commit is contained in:
Cody Boone Ferguson committed 2023-11-13 06:08:26 -08:00
1 parent 95b5938a4e
commit 10b5b47466
5 files changed
+129 -5

No files matched your search

+1
View File
@@ -3,3 +3,4 @@ dlowe.alt
README.poot.md
dlowe.orig
prog.orig
make.1
+39 -5
View File
@@ -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: <https://web.archive.org/web/20001025182142/http://pootpoot.com/p
We are sure that you will find that new web page to make a much
more consistent level of quality. :-)
A CGI script such as:
### Historical remarks:
A CGI script such as:
```sh
#!/bin/sh
@@ -85,9 +93,35 @@ else
fi
```
can be used to pootify web pages.
could be used to pootify web pages. It was noticed in 2023, however, that
`lynx(1)` does not work well and `links(1)` does not have the same security
protections that `lynx(1)` does. Thus it might be unwise to use as a CGI script.
For further information see:
The [pootify.sh](pootify.sh) script has been added which is a modification to
the above which can be used to render html files locally with the added bonus
that one can use `file://` URLs. If one uses it as a CGI script (whether
modifying it to use `lynx(1)` or not) they might want to uncomment the check in
the script for `file://` based URLs. It has not been tested as a CGI script with
lynx(1) so it's maybe possible that it would work this way.
You can use this script, however, to download and generate html files that you
can look at locally in a browser or pipe through `less(1)`. For instance:
```sh
./pootify.sh URL=https://microsoft.com | less
./pootify.sh -r URL=https://microsoft.com > 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.
+25
View File
@@ -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
+53
View File
@@ -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
+11
View File
@@ -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