This fixes text encoding detection for gopher requests which was using
the chardet module without importing it.
Here's a URL that causes a crash before the fix:
gopher://sdf.org/0/users/d1337/textfiles/hacker_crackdown.txt
Flit is the simplest of PEP517 build systems so I used it.
Packagers will need to switch from legacy (setup.py) mode to PEP517, if
not already.
Most offpunk.py changes are stripped whitespace. Relevant are:
- Added module docstring (__doc__ variable)
- Added __version__ variable
These two will be used by Flit so you will need to bump version in one
place only.
Previously, offpunk would send the UTF-8 host in the Gemini request.
This changes it to first IDNA-encode the hostname in the URL before
making the request. This bug only existed for Gemini requests, since the
host is already being encoded for Spartan requests and `requests`
handles this for HTTP URLs.
Additionally, the code now treats both UTF-8 hosts and their IDNA
equivalents as the same host for the purposes of identifying
cross-domain redirects.
Not everyone use zathura and feh so they are not removed by default.
To restore previous behaviour, add the following lines to your offpunkrc:
handler image/* feh -. %s
handler application/pdf zathura %s
In order for `readline` to handle up/down arrow presses with ANSI
escape codes in the prompt, all non-printable characters must be
prefaced with \001 and suffixed with \002. Otherwise, long lines
do not get entirely cleared when scrolling up/down.
This should fix https://notabug.org/ploum/offpunk/issues/9 . This
involves a few closely-related changes to subprogram execution:
- If a path, url or file contents were being passed using `cat` or
`echo`, the code was changed to pass the file/string on stdin. This
also makes several pipelines into single programs and should allow for
the removal of `shell=True` in the future.
- For `file`, `xdg-open` and `less`, which either can't accept their
input on stdin or otherwise use the path, the paths are now being
escaped with `shlex.quote()`.
- Finally, the environment variable $LESSHISTFILE is now being set in
python code, where escaping is not necessary.
Notably, the argument to `grep` in `less_cmd()` is not quoted in this
commit, since I was unsure of how it was meant to be used. If the
argument is not already quoted, this should probably be passed through
`shlex.quote()`.
This does not do the following, which may be desired:
- This does not disable `shell=True` anywhere, since `subprocess.run()`
requires the command to be already split into a list of strings. I
think this would just require a `shlex.split()` in `run()` when this
is disabled, but it may require more thought.
- Some of the invoked programs (with the notable exception of `echo` and
`xdg-open`) support the use of "--" to prevent any following arguments
from being treated as program flags if they start with "-". I don't
believe there are any paths that start with "-", but it may make sense
to include this where possible.
I have briefly tested this commit, but it touches quite a few code
paths, so there might be bugs that I missed.
Fixes a crash when trying to look up the contents of the current index
using `ls` command whenever there is no current page loaded by making a
current item a requirement.