From ffa4e24548e31af0be03895aa61af9e2dee477cc Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Wed, 4 Mar 2026 22:47:20 -0800 Subject: [PATCH] Fix: Stricter title sanitization for backticks and slashes --- src/title-generator.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/title-generator.js b/src/title-generator.js index e77d6c7..bcba17b 100644 --- a/src/title-generator.js +++ b/src/title-generator.js @@ -33,7 +33,11 @@ export const generateTitleWithAI = async messages => { }); if (!r.ok) return null; const d = await r.json(); - return (d.choices?.[0]?.message?.content?.trim() || '').replace(/["']/g, '') || null; + const rawTitle = d.choices?.[0]?.message?.content?.trim() || ''; + + // Now stripping backticks (`), slashes (/ \), and other illegal filename chars + // This turns "`Sune v0 - UI/CSS tools`" into "Sune v0 - UICSS tools" + return rawTitle.replace(/[<>:"/\\|?*\x00-\x1f`]/g, '').trim().replace(/\.$/, '') || null; } catch (e) { console.error('AI title gen failed:', e); return null;