diff --git a/server/src/index.ts b/server/src/index.ts index 580a5de..742c6ae 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -113,14 +113,15 @@ function checkMessageRate(client: Client): boolean { } /** Sanitize client-provided display name */ -function sanitizeName(name: string): string { +function sanitizeName(name: unknown): string { + if (typeof name !== "string") return "Appareil"; return name.trim().slice(0, 30) || "Appareil"; } /** Validate device type */ -function validateDeviceType(dt: string): DeviceType { +function validateDeviceType(dt: unknown): DeviceType { const valid: DeviceType[] = ["phone", "tablet", "laptop", "desktop"]; - return valid.includes(dt as DeviceType) ? (dt as DeviceType) : "laptop"; + return typeof dt === "string" && valid.includes(dt as DeviceType) ? (dt as DeviceType) : "laptop"; } /** Validate avatar (must be a small data URL or undefined) */