chg: Enforce username with only chars

pull/940/head
Raphaël Vinot 2024-09-25 16:37:53 +02:00
parent 8f2361427c
commit 36837a8edc
1 changed files with 4 additions and 0 deletions

View File

@ -20,6 +20,7 @@ from logging import Logger
from pathlib import Path
from pydantic import field_validator
from pydantic_core import from_json
from string import punctuation
from typing import Any, TYPE_CHECKING
from urllib.parse import urlparse
@ -436,6 +437,9 @@ class CaptureSettings(LacuscoreCaptureSettings):
@lru_cache(64)
def load_user_config(username: str) -> dict[str, Any] | None:
if any(c in punctuation for c in username):
# The username is invalid. This should never happen, but let's be safe.
return None
user_config_path = get_homedir() / 'config' / 'users' / f'{username}.json'
if not user_config_path.exists():
return None