mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-12 11:39:33 +02:00
Properly sanitize pagerhist when returning as plain text
This commit is contained in:
@@ -42,12 +42,11 @@ from .notify import NotificationCommand, handle_notification_cmd
|
||||
from .options.types import Options
|
||||
from .rgb import to_color
|
||||
from .terminfo import get_capabilities
|
||||
from .types import MouseEvent, WindowGeometry, ac
|
||||
from .types import MouseEvent, WindowGeometry, ac, run_once
|
||||
from .typing import BossType, ChildType, EdgeLiteral, TabType, TypedDict
|
||||
from .utils import (
|
||||
get_primary_selection, load_shaders, log_error, open_cmd, open_url,
|
||||
parse_color_set, resolve_custom_file, sanitize_title,
|
||||
set_primary_selection, sgr_sanitizer_pat
|
||||
parse_color_set, resolve_custom_file, sanitize_title, set_primary_selection
|
||||
)
|
||||
|
||||
MatchPatternType = Union[Pattern[str], Tuple[Pattern[str], Optional[Pattern[str]]]]
|
||||
@@ -283,8 +282,13 @@ def setup_colors(screen: Screen, opts: Options) -> None:
|
||||
)
|
||||
|
||||
|
||||
@run_once
|
||||
def ansi_sanitizer_pat() -> 're.Pattern[str]':
|
||||
return re.compile(r'\x1b(?:\[.*?m|\].*?\x1b\\)')
|
||||
|
||||
|
||||
def text_sanitizer(as_ansi: bool, add_wrap_markers: bool) -> Callable[[str], str]:
|
||||
pat = sgr_sanitizer_pat()
|
||||
pat = ansi_sanitizer_pat()
|
||||
ansi, wrap_markers = not as_ansi, not add_wrap_markers
|
||||
|
||||
def remove_wrap_markers(line: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user