-
Notifications
You must be signed in to change notification settings - Fork 31
/
html.go
65 lines (48 loc) · 1.11 KB
/
html.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
package processors
import (
"html"
)
type HTMLEncode struct{}
func (p HTMLEncode) Name() string {
return "html-encode"
}
func (p HTMLEncode) Alias() []string {
return []string{"html-enc", "html-escape"}
}
func (p HTMLEncode) Transform(data []byte, _ ...Flag) (string, error) {
return html.EscapeString(string(data)), nil
}
func (p HTMLEncode) Flags() []Flag {
return nil
}
func (p HTMLEncode) Title() string {
return "HTML Encode"
}
func (p HTMLEncode) Description() string {
return "Escape your HTML"
}
func (p HTMLEncode) FilterValue() string {
return p.Title()
}
type HTMLDecode struct{}
func (p HTMLDecode) Name() string {
return "html-decode"
}
func (p HTMLDecode) Alias() []string {
return []string{"html-dec", "html-unescape"}
}
func (p HTMLDecode) Transform(data []byte, _ ...Flag) (string, error) {
return html.UnescapeString(string(data)), nil
}
func (p HTMLDecode) Flags() []Flag {
return nil
}
func (p HTMLDecode) Title() string {
return "HTML Decode"
}
func (p HTMLDecode) Description() string {
return "Unescape your HTML"
}
func (p HTMLDecode) FilterValue() string {
return p.Title()
}