Something went wrong. Try again.
Monorepo for Tangled
Something went wrong. Try again.
markup/sanitizer: build bluemonday policies once at package init master
Both policies were rebuilt on every NewSanitizer() call. This included compiling the chroma syntax-highlight class regex by iterating chroma.StandardTypes and joining ~200 type names into a regex alternation, on every invocation — including from inside the pull request HTTP handler, making it a per-request cost. Move both policies to package-level vars initialized once in init(). NewSanitizer() is now a pair of pointer assignments. This is safe per the bluemonday README: "it is safe to use the policy in multiple goroutines". Signed-off-by: Matías Insaurralde <matias@insaurral.de>
Author Matías Insaurralde Committer Tangled Date (Mar 11, 2026, 10:14 AM UTC) Commit 4fb9e0a1 4fb9e0a189fa7d54968495a70756748f34929c06 Parent ae3c8205 ae3c820543b2e0504fd4f251e76a861d24f7d36c