all repos — honk @ a4d92f2e3fc9ae6692393f6bd22a0b6e609bf30f

my fork of honk

a few more html tags, probably unlikely in AP though
Ted Unangst tedu@tedunangst.com
Fri, 17 May 2019 19:11:17 -0400
commit

a4d92f2e3fc9ae6692393f6bd22a0b6e609bf30f

parent

c771af412c97074b60e9b357bbbbc474e1d34e66

1 files changed, 12 insertions(+), 8 deletions(-)

jump to
M html.gohtml.go

@@ -28,11 +28,14 @@

"golang.org/x/net/html" ) -var permittedtags = []string{"div", "h1", "h2", "h3", "h4", "h5", "h6", - "table", "thead", "tbody", "th", "tr", "td", - "p", "br", "pre", "code", "blockquote", - "strong", "em", "b", "i", "s", "u", "sub", "sup", "del", - "ol", "ul", "li"} +var permittedtags = []string{ + "div", "h1", "h2", "h3", "h4", "h5", "h6", + "table", "thead", "tbody", "th", "tr", "td", "colgroup", "col", + "p", "br", "pre", "code", "blockquote", "q", + "samp", "mark", "ins", "dfn", "cite", "abbr", "address", + "strong", "em", "b", "i", "s", "u", "sub", "sup", "del", "tt", "small", + "ol", "ul", "li", "dl", "dt", "dd", +} var permittedattr = []string{"colspan", "rowspan"} var bannedtags = []string{"script", "style"}

@@ -72,8 +75,7 @@ io.WriteString(w, ">")

} func render(w io.Writer, node *html.Node) { - switch node.Type { - case html.ElementNode: + if node.Type == html.ElementNode { tag := node.Data switch { case tag == "a":

@@ -99,12 +101,14 @@ writetag(w, node)

case contains(bannedtags, tag): return } - case html.TextNode: + } else if node.Type == html.TextNode { io.WriteString(w, html.EscapeString(node.Data)) } + for c := node.FirstChild; c != nil; c = c.NextSibling { render(w, c) } + if node.Type == html.ElementNode { tag := node.Data if tag == "a" || (contains(permittedtags, tag) && tag != "br") {