feat(classes): allow the Blog Editor's own markup in the HTML policy

- figure data-embed ^youtube$ and data-id ^[A-Za-z0-9_-]{11}$ (the embed
  placeholder), img alt with any text, ol start ^[0-9]+$; nothing else
- TestEditorOutputPassesPolicy checks every editor-corpus.json entry byte
  for byte with an empty report, plus the negative cases;
  TestSanitizeHTMLReport pins the removal report
- CheckHTML documented as a predicate no write path refuses with; README
  lists the four additions and the report API
This commit is contained in:
2026-10-10 12:11:29 +02:00
parent cb1c688213
commit 2384a61e38
4 changed files with 292 additions and 8 deletions

View File

@@ -146,6 +146,17 @@ func TestBlogEditorTracerSmoke(t *testing.T) {
}
})
t.Run("decode keeps the embed placeholder", func(t *testing.T) {
const placeholder = `<p>Film:</p><figure data-embed="youtube" data-id="dQw4w9WgXcQ"></figure>`
got, err := decode(t, placeholder)
if err != nil {
t.Fatal(err)
}
if got.Value != placeholder || len(got.Notices) != 0 {
t.Fatalf("Decode(placeholder) = %#v", got)
}
})
t.Run("decode strips and reports", func(t *testing.T) {
got, err := decode(t, `<p>a<script>alert(1)</script></p><img src="https://example.test/x.png" alt="x" onerror="alert(1)">`)
if err != nil {