Fix: Stricter title sanitization for backticks and slashes

This commit is contained in:
2026-03-04 22:47:20 -08:00
parent c6f7352a4a
commit ffa4e24548

View File

@@ -33,7 +33,11 @@ export const generateTitleWithAI = async messages => {
}); });
if (!r.ok) return null; if (!r.ok) return null;
const d = await r.json(); 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) { } catch (e) {
console.error('AI title gen failed:', e); console.error('AI title gen failed:', e);
return null; return null;