This commit is contained in:
Kovid Goyal
2025-08-04 16:12:28 +05:30
parent 23b3c83a84
commit 948d2e6e9c
5 changed files with 9 additions and 9 deletions

View File

@@ -144,7 +144,7 @@ from .utils import (
parse_uri_list,
platform_window_id,
safe_print,
sanitize_url_for_dispay_to_user,
sanitize_url_for_display_to_user,
shlex_split,
startup_notification_handler,
timed_debug_print,
@@ -3160,8 +3160,8 @@ class Boss:
pass
mouse_discard_event = discard_event
def sanitize_url_for_dispay_to_user(self, url: str) -> str:
return sanitize_url_for_dispay_to_user(url)
def sanitize_url_for_display_to_user(self, url: str) -> str:
return sanitize_url_for_display_to_user(url)
def on_system_color_scheme_change(self, appearance: ColorSchemes, is_initial_value: bool) -> None:
theme_colors.on_system_color_scheme_change(appearance, is_initial_value)

View File

@@ -961,7 +961,7 @@ draw_hyperlink_target(OSWindow *os_window, Screen *screen, const CellRenderData
Py_CLEAR(bd->last_drawn_title_object_id);
const char *url = get_hyperlink_for_id(screen->hyperlink_pool, bd->hyperlink_id_for_title_object, true);
if (url == NULL) url = "";
bd->last_drawn_title_object_id = PyObject_CallMethod(global_state.boss, "sanitize_url_for_dispay_to_user", "s", url);
bd->last_drawn_title_object_id = PyObject_CallMethod(global_state.boss, "sanitize_url_for_display_to_user", "s", url);
if (bd->last_drawn_title_object_id == NULL) { PyErr_Print(); return; }
bd->needs_render = true;
}

View File

@@ -1021,7 +1021,7 @@ def sanitize_for_bracketed_paste(text: bytes) -> bytes:
@lru_cache(maxsize=64)
def sanitize_url_for_dispay_to_user(url: str) -> str:
def sanitize_url_for_display_to_user(url: str) -> str:
from urllib.parse import unquote, urlparse, urlunparse
try:
purl = urlparse(url)

View File

@@ -108,7 +108,7 @@ from .utils import (
sanitize_control_codes,
sanitize_for_bracketed_paste,
sanitize_title,
sanitize_url_for_dispay_to_user,
sanitize_url_for_display_to_user,
shlex_split,
)
@@ -1196,7 +1196,7 @@ class Window:
if opts.allow_hyperlinks & 0b10:
from kittens.tui.operations import styled
boss.choose(
'What would you like to do with this URL:\n' + styled(sanitize_url_for_dispay_to_user(url), fg='yellow'),
'What would you like to do with this URL:\n' + styled(sanitize_url_for_display_to_user(url), fg='yellow'),
partial(self.hyperlink_open_confirmed, url, cwd),
'o:Open', 'c:Copy to clipboard', 'n;red:Nothing', default='o',
window=self, title=_('Hyperlink activated'),

View File

@@ -30,7 +30,7 @@ from kitty.fast_data_types import (
)
from kitty.fast_data_types import Cursor as C
from kitty.rgb import to_color
from kitty.utils import is_ok_to_read_image_file, is_path_in_temp_dir, sanitize_title, sanitize_url_for_dispay_to_user, shlex_split, shlex_split_with_positions
from kitty.utils import is_ok_to_read_image_file, is_path_in_temp_dir, sanitize_title, sanitize_url_for_display_to_user, shlex_split, shlex_split_with_positions
from . import BaseTest, filled_cursor, filled_history_buf, filled_line_buf
@@ -466,7 +466,7 @@ class TestDataTypes(BaseTest):
if os.path.isdir('/dev/shm'):
with tempfile.NamedTemporaryFile(dir='/dev/shm') as tf:
self.assertTrue(is_ok_to_read_image_file(tf.name, tf.fileno()), fifo)
self.ae(sanitize_url_for_dispay_to_user(
self.ae(sanitize_url_for_display_to_user(
'h://a\u0430b.com/El%20Ni%C3%B1o/'), 'h://xn--ab-7kc.com/El Niño/')
for x in ('~', '~/', '', '~root', '~root/~', '/~', '/a/b/', '~xx/a', '~~'):
self.assertEqual(os.path.expanduser(x), expanduser(x), x)