b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
Build Skills Index / trigger-deploy (push) Waiting to run
CI / Deny unrelated histories (push) Has been skipped
CI / CI timing report (push) Blocked by required conditions
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / All required checks pass (push) Waiting to run
50 lines
2.2 KiB
Python
50 lines
2.2 KiB
Python
"""Tests for defensive bracketed-paste wrapper stripping in the CLI."""
|
|
|
|
from cli import _strip_leaked_bracketed_paste_wrappers
|
|
|
|
|
|
class TestStripLeakedBracketedPasteWrappers:
|
|
def test_plain_text_unchanged(self):
|
|
text = "hello world"
|
|
assert _strip_leaked_bracketed_paste_wrappers(text) == text
|
|
|
|
def test_strips_canonical_escape_wrappers(self):
|
|
text = "\x1b[200~hello\x1b[201~"
|
|
assert _strip_leaked_bracketed_paste_wrappers(text) == "hello"
|
|
|
|
def test_strips_visible_caret_escape_wrappers(self):
|
|
text = "^[[200~hello^[[201~"
|
|
assert _strip_leaked_bracketed_paste_wrappers(text) == "hello"
|
|
|
|
def test_strips_degraded_bracket_only_wrappers(self):
|
|
text = "[200~hello[201~"
|
|
assert _strip_leaked_bracketed_paste_wrappers(text) == "hello"
|
|
|
|
def test_strips_degraded_bracket_only_wrappers_after_whitespace(self):
|
|
text = "prefix [200~hello[201~ suffix"
|
|
assert _strip_leaked_bracketed_paste_wrappers(text) == "prefix hello suffix"
|
|
|
|
def test_strips_wrapper_fragments_at_boundaries(self):
|
|
text = "00~hello world01~"
|
|
assert _strip_leaked_bracketed_paste_wrappers(text) == "hello world"
|
|
|
|
def test_strips_wrapper_fragments_after_whitespace(self):
|
|
text = "prefix 00~hello world01~ suffix"
|
|
assert _strip_leaked_bracketed_paste_wrappers(text) == "prefix hello world suffix"
|
|
|
|
def test_does_not_strip_non_wrapper_00_tilde_in_normal_text(self):
|
|
text = "build00~tag should stay"
|
|
assert _strip_leaked_bracketed_paste_wrappers(text) == text
|
|
|
|
def test_does_not_strip_non_wrapper_bracket_forms_in_normal_text(self):
|
|
text = "literal[200~tag and literal[201~tag should stay"
|
|
assert _strip_leaked_bracketed_paste_wrappers(text) == text
|
|
|
|
def test_preserves_multiline_content_while_stripping_wrappers(self):
|
|
text = "^[[200~line 1\nline 2\nline 3^[[201~"
|
|
assert _strip_leaked_bracketed_paste_wrappers(text) == "line 1\nline 2\nline 3"
|
|
|
|
def test_preserves_multiline_content_while_stripping_degraded_bracket_only_wrappers(self):
|
|
text = "[200~line 1\nline 2\nline 3[201~"
|
|
assert _strip_leaked_bracketed_paste_wrappers(text) == "line 1\nline 2\nline 3"
|