(t *testing.T)
| 82 | } |
| 83 | |
| 84 | func TestUISanitize(t *testing.T) { |
| 85 | t.Parallel() |
| 86 | |
| 87 | for _, tt := range []struct { |
| 88 | s string |
| 89 | expected string |
| 90 | }{ |
| 91 | {"normal text", "normal text"}, |
| 92 | {"\tfoo \r\\nbar ", "foo bar"}, |
| 93 | {"通常のテキスト", "通常のテキスト"}, |
| 94 | {"foo\nbar", "foo bar"}, |
| 95 | {"foo\tbar", "foo bar"}, |
| 96 | {"foo\rbar", "foo bar"}, |
| 97 | {"foo\x00bar", "foobar"}, |
| 98 | {"\u202Eabc", "abc"}, |
| 99 | {"\u200Bzero width", "zero width"}, |
| 100 | {"foo\x1b[31mred\x1b[0mbar", "fooredbar"}, |
| 101 | {"foo\u0008bar", "foobar"}, |
| 102 | {"foo\x07bar", "foobar"}, |
| 103 | {"foo\uFEFFbar", "foobar"}, |
| 104 | {"<a href='javascript:alert(1)'>link</a>", "link"}, |
| 105 | {"<style>body{display:none}</style>", ""}, |
| 106 | {"<html>HTML</html>", "HTML"}, |
| 107 | {"<br>line break", "line break"}, |
| 108 | {"<link rel='stylesheet' href='evil.css'>", ""}, |
| 109 | {"<img src=1 onerror=alert(1)>", ""}, |
| 110 | {"<!-- comment -->visible", "visible"}, |
| 111 | {"<script>alert('xss')</script>", ""}, |
| 112 | {"<iframe src='evil.com'></iframe>", ""}, |
| 113 | } { |
| 114 | t.Run(tt.expected, func(t *testing.T) { |
| 115 | t.Parallel() |
| 116 | actual := strings.UISanitize(tt.s) |
| 117 | assert.Equal(t, tt.expected, actual) |
| 118 | }) |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | func TestCapitalize(t *testing.T) { |
| 123 | t.Parallel() |
nothing calls this directly
no test coverage detected