Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: common/data/text/sanitizehtml/sanitize_test.go

Issue 2873983003: sanitizehtml: disallow tables (Closed)
Patch Set: simplify Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « common/data/text/sanitizehtml/sanitize.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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&amp;reason=relative-url">link</a>`, 76 `<a rel="noopener" target="_blank" href="about:invalid#s anitized&amp;reason=relative-url">link</a>`,
77 }, 77 },
78 { 78 {
79 `<<a href=abc>`, 79 `<<a href=abc>`,
80 `&lt;<a rel="noopener" target="_blank" href="about:inval id#sanitized&amp;reason=disallowed-scheme"></a>`, 80 `&lt;<a rel="noopener" target="_blank" href="about:inval id#sanitized&amp;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 `&lt;`, 89 `&lt;`,
112 `&lt;`, 90 `&lt;`,
113 }, 91 },
114 { 92 {
(...skipping 17 matching lines...) Expand all
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 }
OLDNEW
« no previous file with comments | « common/data/text/sanitizehtml/sanitize.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698