INNER CODE UNIT · Python
content_disposition
NextWeb4/lan-file-transfer · lan_transfer/api.py:172
def content_disposition(filename: str) -> str:
fallback = "".join(char if 32 <= ord(char) < 127 and char not in '";/\\' else "_" for char in filename)
fallback = fallback or "download"
return f"attachment; filename=\"{fallback}\"; filename*=UTF-8''{quote(filename, safe='')}"
def entry_allowed_groups(entry: dict[str, Any]) -> list[str]:
groups = entry.get("allowed_groups")
if isinstance(groups, list) and groups:
cleaned: list[str] = []
for group in groups:
normalized = GROUP_DEFAULT if str(group) == GROUP_LEGACY_DEFAULT else str(group)
if normalized not in cleaned:
cleaned.append(normalized)
return cleaned or [GROUP_DEFAULT]
return [GROUP_DEFAULT]