fix(html): unescape stripped html entities
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-04 01:59:54 +00:00
parent 9230d3b66c
commit 436bd3716f
2 changed files with 5 additions and 4 deletions

View file

@ -3,6 +3,7 @@
package html
import (
htmlstd "html"
"strings"
"unicode"
@ -48,7 +49,7 @@ func StripTags(html string) string {
b.WriteRune(r)
seenText = true
}
return b.String()
return htmlstd.UnescapeString(b.String())
}
// pipeline.go: Imprint renders a node tree to HTML, strips tags, tokenises the text,

View file

@ -55,10 +55,10 @@ func TestStripTags_NoTags(t *testing.T) {
}
func TestStripTags_Entities(t *testing.T) {
got := StripTags(`&lt;script&gt;`)
want := "&lt;script&gt;"
got := StripTags(`<p>&amp; &lt;script&gt;</p>`)
want := "& <script>"
if got != want {
t.Errorf("StripTags should preserve entities, got %q, want %q", got, want)
t.Errorf("StripTags should unescape entities, got %q, want %q", got, want)
}
}