Sanitise color control responses for shells that still dont use the kitty keyboard protocol

This commit is contained in:
Kovid Goyal 2026-06-09 06:21:15 +05:30
parent 79a768ed55
commit 424fe9991b
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -551,6 +551,8 @@ def color_control(cp: ColorProfile, code: int, value: str | bytes | memoryview =
if isinstance(value, (bytes, memoryview)):
value = str(value, 'utf-8', 'replace')
responses: dict[str, str] = {}
# Only printable ASCII payload allowed as it is echoed back
value = re.sub(r'[^ -~]', '', value)
for rec in value.split(';'):
key, sep, val = rec.partition('=')
if key.startswith('transparent_background_color'):