parse-sdk 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
parse_sdk/_sanitize.py ADDED
@@ -0,0 +1,15 @@
1
+ """Single source for the terminal-control character class.
2
+
3
+ Untrusted strings (server error text, response excerpts) embedded into console
4
+ or exception messages must strip C0 controls (except ``\\t``/``\\n``), DEL, and
5
+ C1 (incl. the single-byte CSI ``\\x9b``) so a hostile value cannot drive the
6
+ operator's terminal. ``_runtime`` (exception-excerpt sanitizing) and
7
+ ``_sync``/``cli`` (console reporting) keep their OWN distinct helpers — one
8
+ truncates, one does not — but share THIS class so the two threat models can
9
+ never drift apart. Stdlib-only leaf module: safe for ``_runtime`` to import."""
10
+ from __future__ import annotations
11
+
12
+ import re
13
+
14
+ # C0 controls except TAB (\x09) and LF (\x0a), DEL (\x7f), and C1 (\x80-\x9f).
15
+ CONTROL_BYTES = re.compile(r"[\x00-\x08\x0b-\x1f\x7f-\x9f]")