MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / sanitize_tsv

Function sanitize_tsv

unity_cli/cli/output.py:161–166  ·  view source on GitHub ↗

Replace control characters to prevent TSV parse breakage and terminal injection.

(value: str)

Source from the content-addressed store, hash-verified

159
160
161def sanitize_tsv(value: str) -> str:
162 """Replace control characters to prevent TSV parse breakage and terminal injection."""
163 # Replace common whitespace control chars with space, strip all other C0 controls
164 result = value.replace("\t", " ").replace("\n", " ").replace("\r", " ")
165 # Remove remaining C0 control characters (0x00-0x1F except already handled) and DEL (0x7F)
166 return result.translate(str.maketrans("", "", "".join(chr(c) for c in range(0x20) if chr(c) not in " ") + "\x7f"))
167
168
169# Keep alias for backward compatibility

Calls

no outgoing calls