github.com/keysonzzz/kmg@v0.0.0-20151121023212-05317bfd7d39/kmgHTMLPurifier/kmgHTMLPurifier_test.go (about) 1 package kmgHTMLPurifier_test 2 3 import ( 4 "strings" 5 "testing" 6 7 "github.com/bronze1man/kmg/kmgHTMLPurifier" 8 "github.com/bronze1man/kmg/kmgTest" 9 ) 10 11 // 过滤 HTML的内容 12 func TestHTMLPurifier(t *testing.T) { 13 input := []string{ 14 `<a onblur="alert(secret)" href="http://www.google.com">Google</a>`, 15 `<a href="http://www.google.com/" target="_blank"><img src="https://ssl.gstatic.com/accounts/ui/logo_2x.png"/></a>`, 16 } 17 for _, content := range input { 18 output := kmgHTMLPurifier.HTMLPurifier(content) 19 kmgTest.Ok(!strings.Contains(output, "alert")) 20 } 21 }