Properly sanitize pagerhist when returning as plain text
This commit is contained in:
parent
53716c084b
commit
711f8b024e
@ -42,12 +42,11 @@ from .notify import NotificationCommand, handle_notification_cmd
|
|||||||
from .options.types import Options
|
from .options.types import Options
|
||||||
from .rgb import to_color
|
from .rgb import to_color
|
||||||
from .terminfo import get_capabilities
|
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 .typing import BossType, ChildType, EdgeLiteral, TabType, TypedDict
|
||||||
from .utils import (
|
from .utils import (
|
||||||
get_primary_selection, load_shaders, log_error, open_cmd, open_url,
|
get_primary_selection, load_shaders, log_error, open_cmd, open_url,
|
||||||
parse_color_set, resolve_custom_file, sanitize_title,
|
parse_color_set, resolve_custom_file, sanitize_title, set_primary_selection
|
||||||
set_primary_selection, sgr_sanitizer_pat
|
|
||||||
)
|
)
|
||||||
|
|
||||||
MatchPatternType = Union[Pattern[str], Tuple[Pattern[str], Optional[Pattern[str]]]]
|
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]:
|
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
|
ansi, wrap_markers = not as_ansi, not add_wrap_markers
|
||||||
|
|
||||||
def remove_wrap_markers(line: str) -> str:
|
def remove_wrap_markers(line: str) -> str:
|
||||||
|
|||||||
@ -1085,4 +1085,4 @@ class TestScreen(BaseTest):
|
|||||||
s = self.create_screen()
|
s = self.create_screen()
|
||||||
draw_prompt('p1')
|
draw_prompt('p1')
|
||||||
draw_output(30)
|
draw_output(30)
|
||||||
self.ae(tuple(map(int, lco()[len('\x1b]133;C\x1b\\'):].split())), tuple(range(0, 30)))
|
self.ae(tuple(map(int, lco().split())), tuple(range(0, 30)))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user