Skip to content

Commit 3b4f9df

Browse files
committed
Fix table insertion into TH tags
Fixes jhy#575
1 parent 5be8b08 commit 3b4f9df

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jsoup changelog
1515
document.
1616
<https://github.com/jhy/jsoup/issues/552>
1717

18+
* Fixed an issue where a table nested within a TH cell would parse to an incorrect tree.
19+
<https://github.com/jhy/jsoup/issues/575>
20+
1821
*** Release 1.8.2 [2015-Apr-13]
1922
* Performance improvements for parsing HTML on Android, of 1.5x to 1.9x, with larger parses getting a bigger
2023
speed increase. For non-Android JREs, around 1.1x to 1.2x.

src/main/java/org/jsoup/parser/HtmlTreeBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ void resetInsertionMode() {
391391
if ("select".equals(name)) {
392392
transition(HtmlTreeBuilderState.InSelect);
393393
break; // frag
394-
} else if (("td".equals(name) || "td".equals(name) && !last)) {
394+
} else if (("td".equals(name) || "th".equals(name) && !last)) {
395395
transition(HtmlTreeBuilderState.InCell);
396396
break;
397397
} else if ("tr".equals(name)) {

src/test/java/org/jsoup/parser/HtmlParserTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,4 +870,10 @@ public void testInvalidTableContents() throws IOException {
870870
assertEquals("<form action=\"/submit\"> <hr> <label>This is a searchable index. Enter search keywords: <input name=\"isindex\"></label> <hr> </form>",
871871
StringUtil.normaliseWhitespace(doc.body().html()));
872872
}
873+
874+
@Test public void testReinsertionModeForThCelss() {
875+
String body = "<body> <table> <tr> <th> <table><tr><td></td></tr></table> <div> <table><tr><td></td></tr></table> </div> <div></div> <div></div> <div></div> </th> </tr> </table> </body>";
876+
Document doc = Jsoup.parse(body);
877+
assertEquals(1, doc.body().children().size());
878+
}
873879
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy