left4me/l4d2web/services/security.py
mwiegand 1166e13e44
feat(l4d2-web): server identity by id, name as display label
Host-side identifier (systemd unit name and /var/lib/left4me dirs) is now
str(server.id), centralized in services/server_identity.server_unit_name.
Server.name becomes a free-form display label, required and unique per
user (was [a-z0-9_-]{1,64} and globally unique).

Migration 0006 swaps the old global UNIQUE(name) for UNIQUE(user_id, name).
Web routes already keyed on id; templates only used name for display.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 19:22:09 +02:00

12 lines
582 B
Python

def validate_overlay_ref(raw: str) -> str:
if raw != raw.strip():
raise ValueError("overlay ref must not have leading or trailing whitespace")
if not raw:
raise ValueError("overlay ref must not be empty")
if "\\" in raw:
raise ValueError("overlay ref must use forward slashes")
if raw.startswith("/"):
raise ValueError("overlay ref must be relative")
if any(component in {"", ".", ".."} for component in raw.split("/")):
raise ValueError("overlay ref must not contain empty, current, or parent components")
return raw