package markup import ( "strings" "testing" ) // Chapter 45.4's attacks, each a permanent test: no tag survives, though inert words may. func TestChapter45Attacks(t *testing.T) { cases := []struct { name, body string forbidden []string }{ {"script tag", ``, []string{"alert(1) there`, []string{"\nalert(1)\n\nb", []string{"`, []string{"onerror", "alert(1)"}}, {"encoded javascript", `x`, []string{"javascript:", "javascript"}}, {"data url", `[x](data:text/html;base64,PHNjcmlwdD4=)`, []string{"data:"}}, {"vbscript", `[x](vbscript:msgbox(1))`, []string{"vbscript:"}}, {"file url", `[x](file:///etc/passwd)`, []string{"file:"}}, {"iframe", ``, []string{"`, []string{"`, []string{"x

`, []string{"style="}}, {"style element", ``, []string{"`, []string{"`, []string{"x`, []string{"javascript:"}}, {"upper case scheme", `x`, []string{"avascript:", "alert(1)"}}, {"null byte scheme", "x", []string{"script:alert"}}, {"meta refresh", ``, []string{"`, []string{" quoted\n\n```go\nfunc main() {}\n```\n\n" + "[forge](https://barerepo.example) and a table:\n\n" + "| a | b |\n|---|---|\n| 1 | 2 |\n" got := Render(body) for _, want := range []string{ "

heading

", "bold", "italic", "code", "