mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
Make NETLOC avaialble to open action commandlines
This commit is contained in:
@@ -64,6 +64,9 @@ some special variables, documented below:
|
||||
``FRAGMENT``
|
||||
The fragment (unquoted), if any of the URL or the empty string.
|
||||
|
||||
``NETLOC``
|
||||
The net location aka hostname (unquoted), if any of the URL or the empty string.
|
||||
|
||||
``URL_PATH``
|
||||
The path, query and fragment portions of the URL, without any
|
||||
unquoting.
|
||||
|
||||
@@ -69,7 +69,7 @@ def parse(lines: Iterable[str]) -> Iterator[OpenAction]:
|
||||
entries.append((tuple(match_criteria), tuple(raw_actions)))
|
||||
|
||||
with to_cmdline_implementation.filter_env_vars(
|
||||
'URL', 'FILE_PATH', 'FILE', 'FRAGMENT', 'URL_PATH',
|
||||
'URL', 'FILE_PATH', 'FILE', 'FRAGMENT', 'URL_PATH', 'NETLOC',
|
||||
EDITOR=shlex.join(get_editor()),
|
||||
SHELL=resolved_shell(get_options())[0]
|
||||
):
|
||||
@@ -164,6 +164,7 @@ def actions_for_url_from_list(url: str, actions: Iterable[OpenAction]) -> Iterat
|
||||
return
|
||||
path = unquote(purl.path)
|
||||
up = purl.path
|
||||
netloc = unquote(purl.netloc) if purl.netloc else ''
|
||||
frag = ''
|
||||
if purl.query:
|
||||
up += f'?{purl.query}'
|
||||
@@ -181,6 +182,7 @@ def actions_for_url_from_list(url: str, actions: Iterable[OpenAction]) -> Iterat
|
||||
'URL_PATH': up,
|
||||
'FILE': posixpath.basename(path),
|
||||
'FRAGMENT': frag,
|
||||
'NETLOC': netloc,
|
||||
}
|
||||
|
||||
def expand(x: Any) -> Any:
|
||||
@@ -236,7 +238,7 @@ def default_open_actions() -> Tuple[OpenAction, ...]:
|
||||
# Open kitty HTML docs links
|
||||
protocol kitty+doc
|
||||
action show_kitty_doc $URL_PATH
|
||||
'''.splitlines()))
|
||||
'''.splitlines()))
|
||||
|
||||
|
||||
@run_once
|
||||
|
||||
@@ -1073,11 +1073,6 @@ class Window:
|
||||
self.handle_remote_file(purl.netloc, unquote(purl.path))
|
||||
return
|
||||
url = urlunparse(purl._replace(netloc=''))
|
||||
if purl.fragment and purl.fragment.startswith('-'):
|
||||
# Dont allow fragments that startwith - as that can lead to arg
|
||||
# injection
|
||||
log_error('Ignoring fragment that starts with - in URL:', url)
|
||||
url = urlunparse(purl._replace(fragment=''))
|
||||
if opts.allow_hyperlinks & 0b10:
|
||||
from kittens.tui.operations import styled
|
||||
boss.choose(
|
||||
|
||||
Reference in New Issue
Block a user