gmnlm: don't assume everything starting with b/f is b/f command

It was impossible to enter a file:// URL because it got interpreted
as a 'f' command without any warning about invalid argument. The same
thing happened with relative addresses beginning with 'b' or 'f'.
gmnlm: save non-sensitive input requests in history

Currently, followup requests to both INPUT and SENSITIVE INPUT responses are
omitted from history. However, the intended use of INPUT is for searching, and
there is SENSITIVE INPUT for sensitive information, so omitting regular INPUT
from history doesn't make much sense and only makes searching annoying as one
needs to re-enter the query when going back.
eb5c5470 — Sebastiano Tronto a month ago
Add d[N] to download Nth link

I wanted to add an optional [N] to 'd' and '|' to download/pipe the
Nth link instead of the current page. After getting the first one done,
I found out that '|' already has this option, so I fixed the relative
help line without changing that command.

All in all I don't know how useful this patch is, considering that
'[N]|' was already there. Feel free to discard it and just keep the
documentation change.

gmni: fix -d truncation

Previously, the last character of the provided input would not be read.
For example, `gmni -d termfmt gemini://godocs.io/-/search` would search
for "termfm".
gmnlm: fix memory leak in do_requests
gmnlm: strip control sequences from plaintext rendering
gmnlm: d <path> -> d [path]

The argument is optional, the 'd' command works without it.
fix null dereference
gmnlm: add optional custom bookmark titles

It is often useful to title a bookmark differently from how the page's
author titled it.
gmnlm: output newline when quiting via Control-D

It is common practice to quit programs reading from stdin by sending
EOF to their input. This commit ensures such an exit is functionally
equivalent to a regular exit via the 'q' command.
gmnlm: update usage to match man page
clear client certificate when none is required

Otherwise we end up using the client certificate
of a previous request and the current request will
fail with a SSL error 26.
fix wrong path length check and error message
allow ~ as home alias in file path for downloads

This works for gmni and gmnlm respectively.
fix missing last line in gmnlm in some cases

closes ~sircmpwn/gmni#64
fix downloading of files

due to the wrong handling in download_resp() files may get
broken (last chunk missing) and file descriptors have not
been closed correctly.

Additionally we now allow downloading of local ressources
as well - for what its worth.
Makefile: update dependencies in pkgconfig
0b55ef24 — René Wagner a year ago
add hints to history for easier navigation

This commit adds simple hints in front of the URIs on the history
page to directly show what needs to be typed to jump to this page.
gmni: headers are not displayed for REDIRECT and INPUT responses in SHOW_HEADERS and ONLY_HEADERS modes

I've noticed headers are not displayed in some cases with -i/-I
specified. For example:

echo "printf" | gmni -i gemini://drewdevault.com/cgi-bin/man.sh
Output: empty

echo "printf" | gmni -IL gemini://drewdevault.com/cgi-bin/man.sh -
Output: 10 Search for a POSIX man page
INPUT header is here, but no REDIRECT header appeared.

The reason is headers processing is done after responses dispatch. So
some responses (redirect and input) are processed and dropped before.
Patch makes this logic a bit clearer imho: print response header before
any processing if mode is not OMIT_HEADERS and then process response body if mode
is not ONLY_HEADERS. It also deduplicates header printing as a bonus.
gmnlm: host freed too early, causing UAF

The host variable is freed too early. If a client certificate is not
found, the later error message in the
variable to produce an incorrect openssl command. This fix just delays
the free to after the switch statement.

Test case:
gmnlm gemini://feeds.drewdevault.com

The following OpenSSL command will generate a certificate for this host:

openssl req -x509 -newkey rsa:4096 \
 -keyout /home/andrew/.local/share/gmni/certs/€Ú-=öU.key \
 -out /home/andrew/.local/share/gmni/certs/€Ú-=öU.crt \
 -days 36500 -nodes

The following OpenSSL command will generate a certificate for this host:

openssl req -x509 -newkey rsa:4096 \
-keyout /home/andrew/.local/share/gmni/certs/feeds.drewdevault.com.key \
-out /home/andrew/.local/share/gmni/certs/feeds.drewdevault.com.crt \
-days 36500 -nodes