| OLD | NEW |
| 1 // Copyright 2017 The LUCI Authors. All rights reserved. | 1 // Copyright 2017 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package sanitizehtml | 5 package sanitizehtml |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "strings" | 9 "strings" |
| 10 "testing" | 10 "testing" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 }, | 73 }, |
| 74 { | 74 { |
| 75 `<a href="https:///foo">link</a>`, | 75 `<a href="https:///foo">link</a>`, |
| 76 `<a rel="noopener" target="_blank" href="about:invalid#s
anitized&reason=relative-url">link</a>`, | 76 `<a rel="noopener" target="_blank" href="about:invalid#s
anitized&reason=relative-url">link</a>`, |
| 77 }, | 77 }, |
| 78 { | 78 { |
| 79 `<<a href=abc>`, | 79 `<<a href=abc>`, |
| 80 `<<a rel="noopener" target="_blank" href="about:inval
id#sanitized&reason=disallowed-scheme"></a>`, | 80 `<<a rel="noopener" target="_blank" href="about:inval
id#sanitized&reason=disallowed-scheme"></a>`, |
| 81 }, | 81 }, |
| 82 | 82 |
| 83 // Tables | |
| 84 { | |
| 85 `<table> | |
| 86 <tr colspan="2"> | |
| 87 <td rowspan=2>a</td> | |
| 88 </tr> | |
| 89 <tr style=""> | |
| 90 <td>b</td> | |
| 91 <td>c</td> | |
| 92 </tr> | |
| 93 </table>`, | |
| 94 `<table> | |
| 95 <tr colspan="2"> | |
| 96 <td rowspan="2">a</td> | |
| 97 </tr> | |
| 98 <tr> | |
| 99 <td>b</td> | |
| 100 <td>c</td> | |
| 101 </tr> | |
| 102 </table>`, | |
| 103 }, | |
| 104 | |
| 105 // Other | 83 // Other |
| 106 { | 84 { |
| 107 `<div><strong>hello</strong></div>`, | 85 `<div><strong>hello</strong></div>`, |
| 108 `<strong>hello</strong>`, | 86 `<strong>hello</strong>`, |
| 109 }, | 87 }, |
| 110 { | 88 { |
| 111 `<`, | 89 `<`, |
| 112 `<`, | 90 `<`, |
| 113 }, | 91 }, |
| 114 { | 92 { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 132 for _, c := range cases { | 110 for _, c := range cases { |
| 133 c := c | 111 c := c |
| 134 Convey(c.in, t, func() { | 112 Convey(c.in, t, func() { |
| 135 buf := &bytes.Buffer{} | 113 buf := &bytes.Buffer{} |
| 136 err := Sanitize(buf, strings.NewReader(c.in)) | 114 err := Sanitize(buf, strings.NewReader(c.in)) |
| 137 So(err, ShouldBeNil) | 115 So(err, ShouldBeNil) |
| 138 So(buf.String(), ShouldEqual, c.out) | 116 So(buf.String(), ShouldEqual, c.out) |
| 139 }) | 117 }) |
| 140 } | 118 } |
| 141 } | 119 } |
| OLD | NEW |