Skip to content

Commit

Permalink
Test : Add test for newly supported attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
subbudvk authored Feb 27, 2024
1 parent d1260eb commit 6e50ad8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/test/java/org/owasp/html/SanitizersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ public static final void testFormatting() {
"<p>Hello, <b onclick=alert(1337)>World</b>!</p>"));
}

@Test
public static final void testTableAttributes() {
String input = "<table><tbody><tr align=\"center\"><th headers=\"test\">Month</th><th scope=\"rowgroup\">Test</th></tr>"
+ "<tr><td headers=\"name\">Test</td><td>A</td></tr><tr><td rowspan=\"2\">Test</td><td>B</td></tr><tr>"
+ "<td colspan=\"2\">Test</td></tr></tbody></table>";
assertEquals(input, Sanitizers.TABLES.sanitize(input));

//Negative test to ensure 'scope' doesn't allow random values
assertEquals("<table><tbody><tr><th></th></tr></tbody></table>\n"
,Sanitizers.TABLES.sanitize("<table><tbody><tr><th scope=\"random\"></th></tr></tbody></table>\n"
+ ""));
}
@Test
public static final void testBlockElements() {
assertEquals("", Sanitizers.BLOCKS.sanitize(null));
Expand Down

0 comments on commit 6e50ad8

Please sign in to comment.