chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:23:54 +08:00
commit ecb5ae4e59
153 changed files with 21551 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
import re
def safe_path_component(name) -> str:
"""Sanitize an LLM-derived identifier for use as a filesystem path component.
Identifiers come from model output over user-supplied story text, so they may
contain separators or traversal sequences; keep word characters (including
CJK), dashes, dots and spaces, replace everything else, and strip leading
dots so the result can never escape or hide within the working directory.
"""
cleaned = re.sub(r"[^\w\-. ]", "_", str(name))
cleaned = cleaned.strip().lstrip(".")
return cleaned or "unnamed"