MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / sanitize_label

Function sanitize_label

graphify/security.py:393–404  ·  view source on GitHub ↗

Strip control characters and cap length. Safe for embedding in JSON data (inside tags) and plain text. For direct HTML injection, wrap the result with html.escape().

(text: str | None)

Source from the content-addressed store, hash-verified

391
392
393def sanitize_label(text: str | None) -> str:
394 """Strip control characters and cap length.
395
396 Safe for embedding in JSON data (inside <script> tags) and plain text.
397 For direct HTML injection, wrap the result with html.escape().
398 """
399 if text is None:
400 return ""
401 text = _CONTROL_CHAR_RE.sub("", str(text))
402 if len(text) > _MAX_LABEL_LEN:
403 text = text[:_MAX_LABEL_LEN]
404 return text
405
406
407# ---------------------------------------------------------------------------

Callers 11

_add_nodeFunction · 0.90
to_htmlFunction · 0.90
_subgraph_to_textFunction · 0.90
_community_headerFunction · 0.90
_tool_get_nodeFunction · 0.90
_tool_get_neighborsFunction · 0.90
_tool_get_communityFunction · 0.90

Calls

no outgoing calls