fix: sanitize_label double-encoding and --wiki missing from skill (#66, #55)

This commit is contained in:
Safi committed 2026-04-08 09:40:21 +01:00
1 parent 3d53287ff6
commit 92b70ce5f4
7 files changed
+49 -14

No files matched your search

+4 -5
View File
@@ -186,13 +186,12 @@ _MAX_LABEL_LEN = 256
def sanitize_label(text: str) -> str:
"""Strip control characters, cap length, then HTML-escape.
"""Strip control characters and cap length.
Applied to all node labels and edge titles before they are embedded
in pyvis HTML output or returned via the MCP server, preventing both
XSS and broken visualisations from malformed source identifiers.
Safe for embedding in JSON data (inside <script> tags) and plain text.
For direct HTML injection, wrap the result with html.escape().
"""
text = _CONTROL_CHAR_RE.sub("", text)
if len(text) > _MAX_LABEL_LEN:
text = text[:_MAX_LABEL_LEN]
return html.escape(text)
return text