diff --git a/lib/icons/sanitize.js b/lib/icons/sanitize.js
new file mode 100644
index 0000000..0d6e518
--- /dev/null
+++ b/lib/icons/sanitize.js
@@ -0,0 +1,16 @@
+// lib/icons/sanitize.js
+// Focused SVG sanitizer for owner-uploaded icons. NOT a general-purpose
+// sanitizer — it removes the script/handler/foreignObject/js-uri vectors that
+// matter for inline-rendered icons. (Owner-only upload behind CF Access.)
+export function sanitizeSvg(input) {
+ let s = Buffer.isBuffer(input) ? input.toString('utf8') : String(input);
+ s = s.replace(/');
+ expect(out).not.toMatch(/script/i);
+ expect(out).toMatch(/ {
+ const out = sanitizeSvg('');
+ expect(out).not.toMatch(/onload|onclick/i);
+ });
+ it('strips unquoted on* handlers', () => {
+ const out = sanitizeSvg('');
+ expect(out).not.toMatch(/onload|onclick/i);
+ });
+ it('neutralizes javascript: hrefs', () => {
+ const out = sanitizeSvg('');
+ expect(out).not.toMatch(/javascript:/i);
+ });
+ it('drops ', () => {
+ const out = sanitizeSvg('');
+ expect(out).not.toMatch(/foreignObject/i);
+ });
+ it('accepts a Buffer', () => {
+ expect(sanitizeSvg(Buffer.from(''))).toMatch(/