mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 17:52:02 +02:00
Some more doc examples
Also disallow fragments that start with -
This commit is contained in:
@@ -31,12 +31,12 @@ following contents:
|
|||||||
# by the hyperlink-grep kitten and nothing else so far.
|
# by the hyperlink-grep kitten and nothing else so far.
|
||||||
protocol file
|
protocol file
|
||||||
fragment_matches [0-9]+
|
fragment_matches [0-9]+
|
||||||
action launch --type=overlay --cwd=current vim +${FRAGMENT} ${FILE_PATH}
|
action launch --type=overlay --cwd=current vim +${FRAGMENT} -- ${FILE_PATH}
|
||||||
|
|
||||||
# Open text files without fragments in the editor
|
# Open text files without fragments in the editor
|
||||||
protocol file
|
protocol file
|
||||||
mime text/*
|
mime text/*
|
||||||
action launch --type=overlay --cwd=current ${EDITOR} ${FILE_PATH}
|
action launch --type=overlay --cwd=current -- ${EDITOR} -- ${FILE_PATH}
|
||||||
|
|
||||||
Now, run a search with::
|
Now, run a search with::
|
||||||
|
|
||||||
|
|||||||
@@ -164,9 +164,16 @@ 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
|
||||||
|
frag = ''
|
||||||
if purl.query:
|
if purl.query:
|
||||||
up += f'?{purl.query}'
|
up += f'?{purl.query}'
|
||||||
if purl.fragment:
|
if purl.fragment:
|
||||||
|
frag = unquote(purl.fragment)
|
||||||
|
if frag.startswith('-'):
|
||||||
|
# Dont allow fragments that startwith - as that can lead to arg
|
||||||
|
# injection
|
||||||
|
log_error('Ignoring fragment that starts with - in URL:', url)
|
||||||
|
frag = ''
|
||||||
up += f'#{purl.fragment}'
|
up += f'#{purl.fragment}'
|
||||||
|
|
||||||
env = {
|
env = {
|
||||||
@@ -174,7 +181,7 @@ def actions_for_url_from_list(url: str, actions: Iterable[OpenAction]) -> Iterat
|
|||||||
'FILE_PATH': path,
|
'FILE_PATH': path,
|
||||||
'URL_PATH': up,
|
'URL_PATH': up,
|
||||||
'FILE': posixpath.basename(path),
|
'FILE': posixpath.basename(path),
|
||||||
'FRAGMENT': unquote(purl.fragment)
|
'FRAGMENT': frag,
|
||||||
}
|
}
|
||||||
|
|
||||||
def expand(x: Any) -> Any:
|
def expand(x: Any) -> Any:
|
||||||
|
|||||||
@@ -1073,6 +1073,11 @@ 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