fix(admin): sanitize the richeditor read-only display with DOMPurify (T-10-16)

- displayHtml uses a dedicated DOMPurify 3.4.16 instance: EDITOR_TAGS, href
  only on <a> through isAllowedLink, DROPPED elements go with their content
- string in, string out: parsed into DOMPurify's inert document, nothing
  adopted into the live document before binding
- fails closed (empty string) unless isSupported and a fixed canary hold
- Vitest browser mode in Playwright Chromium (npm run test:browser) covers
  the clobbering vectors, off-origin form, iframe, meta refresh, links and
  the inert parse; happy-dom keeps engine-independent assertions
This commit is contained in:
2026-10-12 20:35:57 +02:00
parent fba15c9378
commit c1d767f0f8
9 changed files with 522 additions and 45 deletions

View File

@@ -1,4 +1,4 @@
import { defineConfig } from 'vitest/config'
import { configDefaults, defineConfig } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
@@ -6,6 +6,8 @@ export default defineConfig({
test: {
environment: 'happy-dom',
include: ['tests/**/*.test.ts'],
// tests/browser needs a real engine: vitest.browser.config.ts.
exclude: [...configDefaults.exclude, 'tests/browser/**'],
setupFiles: ['tests/setup.ts'],
restoreMocks: true,
},