Skip to content

Commit 85332d0

Browse files
authored
Merge pull request #2 from tobycroft/main
ContainString方法在新版中替换成泛型方法
2 parents 86963cd + 13fce6f commit 85332d0

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/feiin/go-xss
22

33
go 1.12
44

5-
require github.com/feiin/pkg v0.0.0-20200516102027-5ac181da46b6
5+
require github.com/feiin/pkg v0.2.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
github.com/feiin/pkg v0.0.0-20200516102027-5ac181da46b6 h1:yNgjO67CSASFT/dD06ZtNuTO5mC8NOxq8X8qOPcaNpE=
22
github.com/feiin/pkg v0.0.0-20200516102027-5ac181da46b6/go.mod h1:5c1e9ZJud6jYkdjVOwYgNweJcDuFxkh2xiBek0w+hg8=
3+
github.com/feiin/pkg v0.2.1 h1:fqewu0DwUvMHq50jxdQcUumfQ5JjZy4DyH/jfp6JzhI=
4+
github.com/feiin/pkg v0.2.1/go.mod h1:a+eNap+KldbxTPdyChieaQ+z8EUr5h3eXnDliCngMP4=

xss.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type Xss struct {
1212
options XssOption
1313
}
1414

15-
//NewXSS
15+
// NewXSS
1616
func NewXSS(options XssOption) *Xss {
1717

1818
defaultOption := NewDefaultXssOption()
@@ -82,7 +82,7 @@ func GetAttrs(html string) AttrResult {
8282

8383
}
8484

85-
//Process 处理xss
85+
// Process 处理xss
8686
func (x *Xss) Process(html string) string {
8787

8888
if len(html) < 3 {
@@ -153,7 +153,7 @@ func (x *Xss) Process(html string) string {
153153
}
154154

155155
attrsHTML := parseAttr(attrs.Html, func(name, value string) string {
156-
isWhiteAttr := arrays.ContainsString(whiteAttrList, name) != -1
156+
isWhiteAttr := arrays.Contains(whiteAttrList, name) != -1
157157

158158
ret := onTagAttr(tag, name, value, isWhiteAttr)
159159

@@ -211,7 +211,7 @@ func (x *Xss) Process(html string) string {
211211
return retHTML
212212
}
213213

214-
//FilterXSS filter xss func
214+
// FilterXSS filter xss func
215215
func FilterXSS(html string, options XssOption) string {
216216
xss := NewXSS(options)
217217
return xss.Process(html)

0 commit comments

Comments
 (0)