-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdefaults.go
153 lines (146 loc) · 4.99 KB
/
defaults.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package gsoup
import "golang.org/x/net/html/atom"
var simpleTextWhitelist = whitelist{
atom.B: T(atom.B),
atom.Em: T(atom.Em),
atom.I: T(atom.I),
atom.Strong: T(atom.Strong),
atom.U: T(atom.U),
}
var basicWhitelist = whitelist{
atom.A: T(atom.A, "href").EnforceAttr("rel", "nofollow").EnforceProtocols("href", "ftp", "http", "https", "mailto"),
atom.B: T(atom.B),
atom.Blockquote: T(atom.Blockquote, "cite").EnforceProtocols("cite", "http", "https"),
atom.Br: T(atom.Br),
atom.Cite: T(atom.Cite),
atom.Dd: T(atom.Dd),
atom.Dl: T(atom.Dl),
atom.Dt: T(atom.Dt),
atom.Em: T(atom.Em),
atom.I: T(atom.I),
atom.Li: T(atom.Li),
atom.Ol: T(atom.Ol),
atom.P: T(atom.P),
atom.Pre: T(atom.Pre),
atom.Q: T(atom.Q, "cite"),
atom.Small: T(atom.Small),
atom.Span: T(atom.Span),
atom.Strike: T(atom.Strike),
atom.Strong: T(atom.Strong),
atom.Sub: T(atom.Sub),
atom.Sup: T(atom.Sup),
atom.U: T(atom.U),
atom.Ul: T(atom.Ul),
}
var basicWhitelistWithImages = whitelist{
atom.A: T(atom.A, "href").EnforceAttr("rel", "nofollow").EnforceProtocols("href", "ftp", "http", "https", "mailto"),
atom.B: T(atom.B),
atom.Blockquote: T(atom.Blockquote, "cite").EnforceProtocols("cite", "http", "https"),
atom.Br: T(atom.Br),
atom.Cite: T(atom.Cite),
atom.Dd: T(atom.Dd),
atom.Dl: T(atom.Dl),
atom.Dt: T(atom.Dt),
atom.Em: T(atom.Em),
atom.I: T(atom.I),
atom.Img: T(atom.Img, "align", "alt", "height", "src", "title", "width").EnforceProtocols("src", "http", "https"),
atom.Li: T(atom.Li),
atom.Ol: T(atom.Ol),
atom.P: T(atom.P),
atom.Pre: T(atom.Pre),
atom.Q: T(atom.Q, "cite"),
atom.Small: T(atom.Small),
atom.Span: T(atom.Span),
atom.Strike: T(atom.Strike),
atom.Strong: T(atom.Strong),
atom.Sub: T(atom.Sub),
atom.Sup: T(atom.Sup),
atom.U: T(atom.U),
atom.Ul: T(atom.Ul),
}
var relaxedWhitelist = whitelist{
atom.A: T(atom.A, "href", "title").EnforceAttr("rel", "nofollow").EnforceProtocols("href", "ftp", "http", "https", "mailto"),
atom.B: T(atom.B),
atom.Blockquote: T(atom.Blockquote, "cite").EnforceProtocols("cite", "http", "https"),
atom.Br: T(atom.Br),
atom.Caption: T(atom.Caption),
atom.Cite: T(atom.Cite),
atom.Code: T(atom.Code),
atom.Col: T(atom.Col, "span", "width"),
atom.Colgroup: T(atom.Colgroup, "span", "width"),
atom.Dd: T(atom.Dd),
atom.Div: T(atom.Div),
atom.Dl: T(atom.Dl),
atom.Dt: T(atom.Dt),
atom.Em: T(atom.Em),
atom.H1: T(atom.H1),
atom.H2: T(atom.H2),
atom.H3: T(atom.H3),
atom.H4: T(atom.H4),
atom.H5: T(atom.H5),
atom.H6: T(atom.H6),
atom.I: T(atom.I),
atom.Img: T(atom.Img, "align", "alt", "height", "src", "title", "width").EnforceProtocols("src", "http", "https"),
atom.Li: T(atom.Li),
atom.Ol: T(atom.Ol, "start", "type"),
atom.P: T(atom.P),
atom.Pre: T(atom.Pre),
atom.Q: T(atom.Q, "cite").EnforceProtocols("cite", "http", "https"),
atom.Small: T(atom.Small),
atom.Span: T(atom.Span),
atom.Strike: T(atom.Strike),
atom.Strong: T(atom.Strong),
atom.Sub: T(atom.Sub),
atom.Sup: T(atom.Sup),
atom.Table: T(atom.Table, "summary", "width"),
atom.Tbody: T(atom.Tbody),
atom.Td: T(atom.Td, "abbr", "axis", "colspan", "rowspan", "width"),
atom.Tfoot: T(atom.Tfoot),
atom.Th: T(atom.Th, "abbr", "axis", "colspan", "rowspan", "scope", "width"),
atom.Thead: T(atom.Thead),
atom.Tr: T(atom.Tr),
atom.U: T(atom.U),
atom.Ul: T(atom.Ul, "type"),
}
var deleteChildrenSet = Tagset{
atom.Applet: struct{}{},
atom.Area: struct{}{},
atom.Audio: struct{}{},
atom.Base: struct{}{},
atom.Basefont: struct{}{},
atom.Br: struct{}{},
atom.Canvas: struct{}{},
atom.Col: struct{}{},
atom.Colgroup: struct{}{},
atom.Datalist: struct{}{},
atom.Embed: struct{}{},
atom.Frame: struct{}{},
atom.Frameset: struct{}{},
atom.Head: struct{}{},
atom.Hr: struct{}{},
atom.Iframe: struct{}{},
atom.Img: struct{}{},
atom.Input: struct{}{},
atom.Keygen: struct{}{},
atom.Link: struct{}{},
atom.Map: struct{}{},
atom.Menu: struct{}{},
atom.Meta: struct{}{},
atom.Noframes: struct{}{},
atom.Noscript: struct{}{},
atom.Object: struct{}{},
atom.Param: struct{}{},
atom.Progress: struct{}{},
atom.Rp: struct{}{},
atom.Script: struct{}{},
atom.Source: struct{}{},
atom.Style: struct{}{},
atom.Textarea: struct{}{},
atom.Track: struct{}{},
atom.Video: struct{}{},
atom.Wbr: struct{}{},
}
var preserveChildrenSet = Tagset{
atom.Html: struct{}{},
atom.Body: struct{}{},
}