mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Make NETLOC avaialble to open action commandlines
This commit is contained in:
@@ -64,6 +64,9 @@ some special variables, documented below:
|
|||||||
``FRAGMENT``
|
``FRAGMENT``
|
||||||
The fragment (unquoted), if any of the URL or the empty string.
|
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``
|
``URL_PATH``
|
||||||
The path, query and fragment portions of the URL, without any
|
The path, query and fragment portions of the URL, without any
|
||||||
unquoting.
|
unquoting.
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ def parse(lines: Iterable[str]) -> Iterator[OpenAction]:
|
|||||||
entries.append((tuple(match_criteria), tuple(raw_actions)))
|
entries.append((tuple(match_criteria), tuple(raw_actions)))
|
||||||
|
|
||||||
with to_cmdline_implementation.filter_env_vars(
|
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()),
|
EDITOR=shlex.join(get_editor()),
|
||||||
SHELL=resolved_shell(get_options())[0]
|
SHELL=resolved_shell(get_options())[0]
|
||||||
):
|
):
|
||||||
@@ -164,6 +164,7 @@ def actions_for_url_from_list(url: str, actions: Iterable[OpenAction]) -> Iterat
|
|||||||
return
|
return
|
||||||
path = unquote(purl.path)
|
path = unquote(purl.path)
|
||||||
up = purl.path
|
up = purl.path
|
||||||
|
netloc = unquote(purl.netloc) if purl.netloc else ''
|
||||||
frag = ''
|
frag = ''
|
||||||
if purl.query:
|
if purl.query:
|
||||||
up += f'?{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,
|
'URL_PATH': up,
|
||||||
'FILE': posixpath.basename(path),
|
'FILE': posixpath.basename(path),
|
||||||
'FRAGMENT': frag,
|
'FRAGMENT': frag,
|
||||||
|
'NETLOC': netloc,
|
||||||
}
|
}
|
||||||
|
|
||||||
def expand(x: Any) -> Any:
|
def expand(x: Any) -> Any:
|
||||||
|
|||||||
@@ -1073,11 +1073,6 @@ class Window:
|
|||||||
self.handle_remote_file(purl.netloc, unquote(purl.path))
|
self.handle_remote_file(purl.netloc, unquote(purl.path))
|
||||||
return
|
return
|
||||||
url = urlunparse(purl._replace(netloc=''))
|
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:
|
if opts.allow_hyperlinks & 0b10:
|
||||||
from kittens.tui.operations import styled
|
from kittens.tui.operations import styled
|
||||||
boss.choose(
|
boss.choose(
|
||||||
|
|||||||
Reference in New Issue
Block a user