Trust route.CaptchaWidget markup in plugin HTML output

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Alex Dunmow 2026-11-20 06:34:57 +08:00
parent 1a8347a9e5
commit bd55930870
2 changed files with 3 additions and 2 deletions

View File

@ -468,7 +468,7 @@ func (c *htmlChecker) safeCall(call *ast.CallExpr) bool {
// trustedHTMLRenderers are host and library methods that return sanitized
// HTML: the pluginsdk content service's BlockNote renderer and bluemonday.
var trustedHTMLRenderers = map[string]bool{"BlockNoteToHTML": true, "Sanitize": true}
var trustedHTMLRenderers = map[string]bool{"BlockNoteToHTML": true, "Sanitize": true, "CaptchaWidget": true}
func stringOr(e ast.Expr) string {
s, _ := stringLit(e)

View File

@ -6,6 +6,7 @@ import (
"git.dev.alexdunmow.com/block/pluginsdk/blocks"
"git.dev.alexdunmow.com/block/pluginsdk/plugin"
"git.dev.alexdunmow.com/block/pluginsdk/route"
"git.dev.alexdunmow.com/block/pluginsdk/templates"
"git.dev.alexdunmow.com/private/quote-requests-a1a5c0/db"
)
@ -43,7 +44,7 @@ func renderForm(_ context.Context, content map[string]any) string {
return `<section class="quote-request-form"><h2>` + str(content, "heading") + `</h2>` +
`<form method="post" action="/api/plugins/` + pluginName + `/submit">` +
`<input name="name"><input name="email" type="email"><input name="property_address">` +
`<textarea name="roof_issue"></textarea><button type="submit">` + button + `</button></form></section>`
`<textarea name="roof_issue"></textarea>` + route.CaptchaWidget() + `<button type="submit">` + button + `</button></form></section>`
}
// renderRecent lists the latest requests that visitors submitted.