Commit Graph

141 Commits

Author SHA1 Message Date
Lionel Dricot 9ee95e7a1b pictures are working 2023-07-30 23:12:01 +02:00
Sotiris Papatheodorou - sotiris at papatheodorou.xyz 2cc599afdd Change the Gopher index filename to gophermap
This seems to be the most common convention among gopher servers (e.g.
Gophernicus, go-gopher).

Added a script to migrate the cache to the new format. Alternatively the
following command can be used for migration in a POSIX system:

find ~/.cache/offpunk/gopher/ -type f -name 'index.txt' -exec sh -c 'mv {} "$(dirname {})/gophermap"' \;
2023-04-14 11:11:24 +02:00
Maeve Sproule - code at sprock.dev a73790f0fb Rewrite gopher URL parsing code per RFC 4266
The previous code was using the first path segment as an item type, if
it was present and a single character long. However, the standard
requires the first character after the slash to be used, if present,
regardless of whether if forms a complete path segment. This rewrite
conforms the code to the standards behaviour, and fixes both the
original problem with gopher://alexschroeder.ch/ and the problem created
with other gopherholes in my attempt to fix it.

I've also changed one piece of code that generates a gopher URL to
better conform to the standard, by avoiding the introduction of leading
slashes. This should prevent any gopherholes that don't accept leading
slashes (including gopher://alexschroeder.ch/) from having problems with
requests sent from offpunk.
2023-04-09 12:10:34 +02:00
Maeve Sproule - code at sprock.dev be2836e218 Fix gopher requests 2023-04-08 22:09:30 +02:00
Lionel Dricot 5b0e63b5a5 should fix gopher requests 2023-04-03 23:18:45 +02:00
Sotiris Papatheodorou - sotiris at papatheodorou.xyz 454994002a Fix merging dictionaries with common keys
The previous code would throw KeyError if a key was present in both
os.environ and env, e.g. when LESSHISTFILE is defined in the
environment. The current code ensures that for keys present in both
dictionaries the value from env will be used.
2023-04-02 14:39:56 +02:00
Lionel Dricot fff1f39877 set accept_bad_certificates now also works for expired Gemini certificates 2023-03-30 11:28:58 +02:00
Lionel Dricot a0ce56d45e Adding chardet to README 2023-03-27 20:51:03 +02:00
Sotiris Papatheodorou - sotiris at papatheodorou.xyz dc38a3f9bc Add missing chardet module
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
2023-03-27 17:39:54 +02:00
Lionel Dricot faf5e0c649 version 1.9.2 2023-03-13 17:02:15 +01:00
Lionel Dricot 8da1eff920 changelog for 3.7 2023-03-12 19:54:02 +01:00
Lionel Dricot 7a05e211e6 changelog for flit 2023-03-12 12:53:27 +01:00
Lionel Dricot 65a445627e release 1.9.1 to fix #8 2023-03-08 23:11:32 +01:00
Lionel Dricot ca6728e607 1.9 2023-03-08 11:21:04 +01:00
Lionel Dricot 520b53f2a3 man page created by phoebos 2023-03-07 16:23:25 +01:00
Lionel Dricot d14e1ba0a9 fix bug #11 2023-03-07 14:36:24 +01:00
Lionel Dricot 2fd2479b53 Assume utf-8 when the header answers with an unknown encoding 2023-03-05 22:57:34 +01:00
Lionel Dricot 891684136f fixing a crash related to bug #10 2023-03-03 15:21:03 +01:00
Lionel Dricot 2b4162be5b Fix a crash by casting HTML content a string (for whatever reason, it is sometimes
seen as bytes)
2023-02-15 15:54:11 +01:00
Lionel Dricot d8771cb267 Revert ""set cache" now allows to set a custom cache folder."
This reverts commit 2582e00cab.
2023-02-15 15:22:09 +01:00
Lionel Dricot 2582e00cab "set cache" now allows to set a custom cache folder.
The implementation is bad as it uses a global variable.
Also, there’s currently no way to revert to the default without restarting offpunk.
2023-01-26 15:20:48 +01:00
Lionel Dricot 6fd1bd4341 Improve compatibility with python 3.7 by replacing a dict union 2023-01-13 09:56:29 +01:00
Lionel Dricot 3438a94155 This should fix #7
Starting now, we don’t assume a valid GeminiItem and thus a valid cache_path.
More crashes might be uncovered.
2023-01-12 17:11:54 +01:00
Lionel Dricot 99e3fc1772 fix error handling assuming that requests is installed 2022-12-29 14:44:09 +01:00
Maeve Sproule - code at sprock.dev 5b432112d0 Fix support for UTF-8 domains in Gemini (fixes #5)
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.
2022-12-22 12:13:47 +01:00
Sotiris Papatheodorou - sotiris at papatheodorou.xyz 39669df9ec Handle .. as an alias to the up command
* It allows passing an argument as in the up command.
* Prevents some weird errors when passing an argument.
2022-12-16 12:40:36 +01:00
Lionel Dricot d1cbe0acf0 Default handlers have been removed.
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
2022-12-12 15:57:28 +01:00
Lionel Dricot 194e9ed62d fix crash when susbcribing without GI 2022-12-12 15:30:49 +01:00
Ben Winston - ben at benwinston.us 1667952153 bugfix: don't crash when there's no links to index 2022-12-11 00:51:42 +01:00
Ben Winston - ben at benwinston.us 95d48fb38d bugfix: readline needs ANSI codes escaped
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.
2022-12-10 22:22:18 +01:00
Lionel Dricot 1754f7a9dd preparing 1.8 release 2022-12-10 22:16:12 +01:00
Lionel Dricot 7bcd0e2af5 fixing a crash with data:image svg 2022-12-02 12:49:37 +01:00
Lionel Dricot af65662f0f Fix images not being downloaded for "full" mode
(the mode was not preserved for each call. We now default to the gi.last_mode if 
no mode is explicitely set during the _go_to_gi call)
2022-12-01 17:39:04 +01:00
Maeve Sproule - code at sprock.dev 1f516b6733 Avoid passing improperly escaped paths to shell
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.
2022-12-01 17:07:44 +01:00
Lionel Dricot e76b2a13e0 accept_bad_ssl_certificates with --assume-yes 2022-11-30 21:02:17 +01:00
Lionel Dricot c15d452d34 deprecating restricted mode 2022-11-30 20:57:23 +01:00
Lionel Dricot fc8cb2f163 moved all references to sourcehut repository 2022-11-30 16:07:33 +01:00
Lionel Dricot 1c9380835c removing dependency on cgi and implementing our own mime parser 2022-11-30 00:11:44 +01:00
Lionel Dricot 75b20e4982 deep bug in handling display modes that became apparent by breaking cp raw 2022-11-27 01:15:37 +01:00
Sotiris Papatheodorou - sotiris at papatheodorou.xyz c02eba5e3e add support for the finger protocol 2022-11-24 12:36:55 +01:00
Lionel Dricot afa89097b2 better feedback when streaming 2022-11-24 10:48:38 +01:00
Lionel Dricot 2d5c17d2fd changelog 2022-11-21 00:07:21 +01:00
Lionel Dricot 2e566f7220 accept localhost as a valid url 2022-11-16 21:45:51 +01:00
Lionel Dricot ff04177d53 set accept_bad_ssl_certificates 2022-11-16 14:44:47 +01:00
Lionel Dricot 06b2a56ed3 certdir variable was not initialised without HAS_CRYPTOGRAPHY (see bug #2) 2022-11-16 10:06:35 +01:00
Lionel Dricot 7baccbb15f v 1.7.1 2022-11-15 17:01:13 +01:00
Lionel Dricot af361bd4ad typo in changelog 2022-11-15 14:13:37 +01:00
Lionel Dricot 041146e3f1 offpunk 1.7 2022-11-15 13:55:39 +01:00
Lionel Dricot 539b287901 new search and wikipedia commands 2022-11-14 21:33:40 +01:00
Lionel Dricot f9b8ccaf9b hidden links in gopher/gemini 2022-11-10 23:50:16 +01:00