aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitri Shuralyov <dmitshur@golang.org>2026-02-18 15:06:18 -0500
committerGopher Robot <gobot@golang.org>2026-03-25 11:01:16 -0700
commitffce12f94f43948bb525fc20068c675227d725c0 (patch)
treebc8b06234c52e976f3a5793281d4a7f8efd6e02c
parent9dabf8b0d4286f37f75289f188edafb77d86b54d (diff)
downloadgo-x-website-ffce12f94f43948bb525fc20068c675227d725c0.tar.xz
cmd/golangorg: catch instances of bad escaping due to template use
The {{raw `…`}} sequence is commonly used in Markdown templates to include a block as is. If such a sequence is used in a Markdown file while its 'template' field in metadata is accidentally set to off (the new default value as of go.dev/cl/733500), it gets rendered as '{{raw <code>' HTML which is almost certainly not what was intended. It should be possible to catch these in TestAll. For golang/go#78211. Change-Id: I7bba708bc41a6421f3aae88e10d30574de7a9294 Reviewed-on: https://go-review.googlesource.com/c/website/+/746741 Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
-rw-r--r--cmd/golangorg/server_test.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/cmd/golangorg/server_test.go b/cmd/golangorg/server_test.go
index be655657..24ef46e0 100644
--- a/cmd/golangorg/server_test.go
+++ b/cmd/golangorg/server_test.go
@@ -48,6 +48,7 @@ var bads = []string{
" < ",
"<-",
"& ",
+ "{{raw <code>",
}
var ignoreBads = []string{
@@ -55,8 +56,8 @@ var ignoreBads = []string{
`window["location"] && window["location"]["hostname"] == "go.dev/talks"`,
}
-// findBad returns (only) the lines containing badly escaped HTML in body.
-// If findBad returns the empty string, there is no badly escaped HTML.
+// findBad returns (only) the lines containing badly escaped sequences in the given HTML body.
+// If findBad returns the empty string, there were no badly escaped sequences detected.
func findBad(body string) string {
lines := strings.SplitAfter(body, "\n")
var out []string