@@ -50,12 +50,44 @@ func ReplaceSanitizer() {
50
50
// Allow keyword markup
51
51
sanitizer .policy .AllowAttrs ("class" ).Matching (regexp .MustCompile (`^` + keywordClass + `$` )).OnElements ("span" )
52
52
53
- // Allow <kbd> tags for keyboard shortcut styling
54
- sanitizer .policy .AllowElements ("kbd" )
55
-
56
53
// Allow classes for anchors
57
54
sanitizer .policy .AllowAttrs ("class" ).Matching (regexp .MustCompile (`ref-issue` )).OnElements ("a" )
58
55
56
+ // Allow generally safe attributes
57
+ generalSafeAttrs := []string {"abbr" , "accept" , "accept-charset" ,
58
+ "accesskey" , "action" , "align" , "alt" ,
59
+ "aria-describedby" , "aria-hidden" , "aria-label" , "aria-labelledby" ,
60
+ "axis" , "border" , "cellpadding" , "cellspacing" , "char" ,
61
+ "charoff" , "charset" , "checked" ,
62
+ "clear" , "cols" , "colspan" , "color" ,
63
+ "compact" , "coords" , "datetime" , "dir" ,
64
+ "disabled" , "enctype" , "for" , "frame" ,
65
+ "headers" , "height" , "hreflang" ,
66
+ "hspace" , "ismap" , "label" , "lang" ,
67
+ "maxlength" , "media" , "method" ,
68
+ "multiple" , "name" , "nohref" , "noshade" ,
69
+ "nowrap" , "open" , "prompt" , "readonly" , "rel" , "rev" ,
70
+ "rows" , "rowspan" , "rules" , "scope" ,
71
+ "selected" , "shape" , "size" , "span" ,
72
+ "start" , "summary" , "tabindex" , "target" ,
73
+ "title" , "type" , "usemap" , "valign" , "value" ,
74
+ "vspace" , "width" , "itemprop" ,
75
+ }
76
+
77
+ generalSafeElements := []string {
78
+ "h1" , "h2" , "h3" , "h4" , "h5" , "h6" , "h7" , "h8" , "br" , "b" , "i" , "strong" , "em" , "a" , "pre" , "code" , "img" , "tt" ,
79
+ "div" , "ins" , "del" , "sup" , "sub" , "p" , "ol" , "ul" , "table" , "thead" , "tbody" , "tfoot" , "blockquote" ,
80
+ "dl" , "dt" , "dd" , "kbd" , "q" , "samp" , "var" , "hr" , "ruby" , "rt" , "rp" , "li" , "tr" , "td" , "th" , "s" , "strike" , "summary" ,
81
+ "details" , "caption" , "figure" , "figcaption" ,
82
+ "abbr" , "bdo" , "cite" , "dfn" , "mark" , "small" , "span" , "time" , "wbr" ,
83
+ }
84
+
85
+ sanitizer .policy .AllowAttrs (generalSafeAttrs ... ).OnElements (generalSafeElements ... )
86
+
87
+ sanitizer .policy .AllowAttrs ("itemscope" , "itemtype" ).OnElements ("div" )
88
+
89
+ // FIXME: Need to handle longdesc in img but there is no easy way to do it
90
+
59
91
// Custom keyword markup
60
92
for _ , rule := range setting .ExternalSanitizerRules {
61
93
if rule .Regexp != nil {
0 commit comments