Commit Graph

856 Commits

Author SHA1 Message Date
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 b1de7c59e4 forgot debug statement 2023-04-04 20:57:17 +02:00
Lionel Dricot 5b0e63b5a5 should fix gopher requests 2023-04-03 23:18:45 +02:00
Lionel Dricot 25b2c4ef53 removing an else condition which is obviously crashing and should not be there 2023-04-03 21:18:42 +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
Anna “CyberTailor” - cyber+misc at sysrq.in 453f8af9f9 add chardet to optional dependencies 2023-03-27 20:45:41 +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
Anna “CyberTailor” 5ddc06b903 bump requires-python to >=3.7 2023-03-12 19:52:58 +01:00
Lionel Dricot 7a05e211e6 changelog for flit 2023-03-12 12:53:27 +01:00
Anna “CyberTailor” 46668d2b4c switch to a PEP517 build system
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.
2023-03-12 12:52:43 +01:00
Lionel Dricot 826aa4e1c2 incrementing to 1.9.1 2023-03-11 00:00:32 +01:00
Lionel Dricot 65a445627e release 1.9.1 to fix #8 2023-03-08 23:11:32 +01:00
Lionel Dricot 1333d1b8e6 added debian package to README 2023-03-08 11:39:11 +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 f7a773d03a removing custom debian 2023-02-28 19:56:23 +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 39b5abeeac unionising env and os.environ should give precedence to env 2023-01-13 22:38:27 +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
Lionel Dricot 7e363f740b better feedback of streaming urls 2022-12-18 20:09:48 +01:00
Lionel Dricot 5a5ff15f90 blocking doubleclick.net by default 2022-12-16 21:03:44 +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 250f3ebe66 added a comment about a function because it took me 15 minutes to understand why it was there 2022-12-14 16:26:03 +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
Lionel Dricot 45a689a5b8 RELEASE 1.8 2022-12-10 22:46:23 +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 49705594f8 updating readme 2022-12-10 21:50:43 +01:00
Ben Winston - ben at benwinston.us 8875a0068c Detecting "New" Chafa 2022-12-09 22:51:34 +01:00
Lionel Dricot 7d57fd9919 adding a space after autocompleting a list 2022-12-07 23:23:31 +01:00
Lionel Dricot b773243623 misplaced check for mode was breaking elif 2022-12-02 13:11:26 +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