From 77c22916a871b75c2066786935786970ff581880 Mon Sep 17 00:00:00 2001 From: Sushil Kumar <51832450+RAY-EZ@users.noreply.github.com> Date: Tue, 20 Jan 2026 23:32:03 +0530 Subject: [PATCH] Fix: Save complete app state (#40) * pass rest of appState in put request * fix: support both legacy and current currentItemRoundness formats Add union type to accept both the old object format {type, value} and the new enum format for backwards compatibility with existing drawings. --------- Co-authored-by: Zimeng Xiong --- backend/src/security.ts | 38 ++++++++++++++++++++++++----------- frontend/src/pages/Editor.tsx | 1 + 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/backend/src/security.ts b/backend/src/security.ts index 87287ed..8696b11 100644 --- a/backend/src/security.ts +++ b/backend/src/security.ts @@ -30,7 +30,9 @@ let activeConfig: SecurityConfig = { ...defaultConfig }; * Configure security settings * @param config Partial configuration to merge with defaults */ -export const configureSecuritySettings = (config: Partial): void => { +export const configureSecuritySettings = ( + config: Partial +): void => { activeConfig = { ...activeConfig, ...config }; }; @@ -318,10 +320,13 @@ export const appStateSchema = z .optional() .nullable(), currentItemRoundness: z - .object({ - type: z.enum(["round", "sharp"]), - value: z.number().finite().min(0).max(1), - }) + .union([ + z.enum(["sharp", "round"]), + z.object({ + type: z.enum(["round", "sharp"]), + value: z.number().finite().min(0).max(1), + }), + ]) .optional() .nullable(), currentItemFontSize: z @@ -427,10 +432,19 @@ export const sanitizeDrawingData = (data: { ]; // Dangerous URL protocols to block entirely - const dangerousProtocols = [/^javascript:/i, /^vbscript:/i, /^data:text\/html/i]; + const dangerousProtocols = [ + /^javascript:/i, + /^vbscript:/i, + /^data:text\/html/i, + ]; // Suspicious patterns for security validation within data URLs - const suspiciousPatterns = [/