diff --git a/src/cms/admin/HistoryPanel.tsx b/src/cms/admin/HistoryPanel.tsx index 2be84c1..3f90d9c 100644 --- a/src/cms/admin/HistoryPanel.tsx +++ b/src/cms/admin/HistoryPanel.tsx @@ -2,15 +2,20 @@ import { useEffect, useRef, useState } from 'react' import type { Post, SiteContent } from '../types' import { getVersion, listVersions } from '../api' import { resolveContent } from '../store' -import { sanitiseBody, slugify } from '../sanitise' +import { sanitiseBody, sanitiseInline, slugify } from '../sanitise' // A version snapshot or an imported content file was written by *some* prior // publish, possibly by an older build with looser sanitisation. Re-sanitising // on the way back in is idempotent for already-clean bodies and closes off any // stored-XSS route through a crafted "content file" or stale studio draft. +// Both fields matter: applyContent() (src/cms/store.tsx) writes content.content +// straight into the DOM via innerHTML as soon as this loads into the editor — +// before the admin ever clicks Publish — so it needs the same treatment as +// article bodies, not just a same-shape skip. const sanitisePosts = (content: SiteContent): SiteContent => ({ ...content, posts: content.posts.map((p) => ({ ...p, body: sanitiseBody(p.body) })), + content: Object.fromEntries(Object.entries(content.content || {}).map(([id, html]) => [id, sanitiseInline(html)])), }) interface Props {