Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/org/owasp/html/HtmlElementTables.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ public HtmlElementTables(
TD_TAG, new int[] { TR_TAG, TD_TAG, TH_TAG },
new int[] { TABLE_TAG, TBODY_TAG, TR_TAG }),
new FreeWrapper(
TH_TAG, new int[] { TR_TAG, TD_TAG, TR_TAG },
TH_TAG, new int[] { TR_TAG, TD_TAG, TH_TAG },
new int[] { TABLE_TAG, TBODY_TAG, TR_TAG }),
new FreeWrapper(
TR_TAG, new int[] { TBODY_TAG, THEAD_TAG, TFOOT_TAG, TR_TAG },
TR_TAG, new int[] { TBODY_TAG, THEAD_TAG, TFOOT_TAG, TR_TAG, TD_TAG, TH_TAG },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are TD & TH required here?

Copy link
Author

@sneha-patil-synacor sneha-patil-synacor Oct 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are three rows in this table.
Without TD, it starts new table from second table row
Without TH, it starts new table from third table row

new int[] { TABLE_TAG, TBODY_TAG }),
new FreeWrapper(
TBODY_TAG, new int[] { TABLE_TAG, THEAD_TAG, TBODY_TAG, TFOOT_TAG },
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/org/owasp/html/ExamplesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,13 @@ public static final void testTextAllowedInLinks() {
"<a href=\"../good.html\" rel=\"nofollow\">click here</a>",
sanitized);
}

@Test
public static final void testTableStructure() {
String input = "<TABLE><TR><TD>Green Zone Bulk mail<TD>21 entries<TR><TH>Type<TH>Date<TH>Size<TH>Country<TR><TD>Junk<TD>March 26<TD>25KB<TD>US";
String sanitized = Sanitizers.TABLES.sanitize(input);
assertEquals(
"<table><tbody><tr><td>Green Zone Bulk mail</td><td>21 entries</td></tr><tr><th>Type</th><th>Date</th><th>Size</th><th>Country</th></tr><tr><td>Junk</td><td>March 26</td><td>25KB</td><td>US</td></tr></tbody></table>",
sanitized);
}
}