From: <mgu...@us...> - 2009-12-14 19:53:13
|
Revision: 271 http://nekohtml.svn.sourceforge.net/nekohtml/?rev=271&view=rev Author: mguillem Date: 2009-12-14 19:53:07 +0000 (Mon, 14 Dec 2009) Log Message: ----------- only end TABLE can close a table Issue #2913095 Modified Paths: -------------- trunk/doc/changes.html trunk/src/org/cyberneko/html/HTMLTagBalancer.java Added Paths: ----------- trunk/data/table/test-tbody-end-cant-end-nested-table.html trunk/data/table/test-tbody-end-cant-end-nested-table.html.canonical trunk/data/table/test-td-end-cant-end-nested-table.html trunk/data/table/test-td-end-cant-end-nested-table.html.canonical trunk/data/table/test-tr-end-cant-end-nested-table.html trunk/data/table/test-tr-end-cant-end-nested-table.html.canonical Added: trunk/data/table/test-tbody-end-cant-end-nested-table.html =================================================================== --- trunk/data/table/test-tbody-end-cant-end-nested-table.html (rev 0) +++ trunk/data/table/test-tbody-end-cant-end-nested-table.html 2009-12-14 19:53:07 UTC (rev 271) @@ -0,0 +1,8 @@ +<table id=tbl-a> +<tbody><tr><td> +<table id=tbl-b> +</tbody> +<tr><td id=td-b1></td></tr> +</table> +</td></tr> +</tbody></table> Added: trunk/data/table/test-tbody-end-cant-end-nested-table.html.canonical =================================================================== --- trunk/data/table/test-tbody-end-cant-end-nested-table.html.canonical (rev 0) +++ trunk/data/table/test-tbody-end-cant-end-nested-table.html.canonical 2009-12-14 19:53:07 UTC (rev 271) @@ -0,0 +1,32 @@ +(HTML +(HEAD +)HEAD +(BODY +(TABLE +Aid tbl-a +"\n +(TBODY +(TR +(TD +"\n +(TABLE +Aid tbl-b +"\n\n +(TBODY +(TR +(TD +Aid td-b1 +)TD +)TR +"\n +)TBODY +)TABLE +"\n +)TD +)TR +"\n +)TBODY +)TABLE +"\n +)BODY +)HTML Added: trunk/data/table/test-td-end-cant-end-nested-table.html =================================================================== --- trunk/data/table/test-td-end-cant-end-nested-table.html (rev 0) +++ trunk/data/table/test-td-end-cant-end-nested-table.html 2009-12-14 19:53:07 UTC (rev 271) @@ -0,0 +1,8 @@ +<table id=tbl-a> +<tr><td> +<table id=tbl-b> +</td> +<tr><td id=td-b1></td></tr> +</table> +</td></tr> +</table> Added: trunk/data/table/test-td-end-cant-end-nested-table.html.canonical =================================================================== --- trunk/data/table/test-td-end-cant-end-nested-table.html.canonical (rev 0) +++ trunk/data/table/test-td-end-cant-end-nested-table.html.canonical 2009-12-14 19:53:07 UTC (rev 271) @@ -0,0 +1,32 @@ +(HTML +(HEAD +)HEAD +(BODY +(TABLE +Aid tbl-a +"\n +(TBODY +(TR +(TD +"\n +(TABLE +Aid tbl-b +"\n\n +(TBODY +(TR +(TD +Aid td-b1 +)TD +)TR +"\n +)TBODY +)TABLE +"\n +)TD +)TR +"\n +)TBODY +)TABLE +"\n +)BODY +)HTML Added: trunk/data/table/test-tr-end-cant-end-nested-table.html =================================================================== --- trunk/data/table/test-tr-end-cant-end-nested-table.html (rev 0) +++ trunk/data/table/test-tr-end-cant-end-nested-table.html 2009-12-14 19:53:07 UTC (rev 271) @@ -0,0 +1,8 @@ +<table id=tbl-a> +<tr><td> +<table id=tbl-b> +</tr> +<tr><td id=td-b1></td></tr> +</table> +</td></tr> +</table> Added: trunk/data/table/test-tr-end-cant-end-nested-table.html.canonical =================================================================== --- trunk/data/table/test-tr-end-cant-end-nested-table.html.canonical (rev 0) +++ trunk/data/table/test-tr-end-cant-end-nested-table.html.canonical 2009-12-14 19:53:07 UTC (rev 271) @@ -0,0 +1,32 @@ +(HTML +(HEAD +)HEAD +(BODY +(TABLE +Aid tbl-a +"\n +(TBODY +(TR +(TD +"\n +(TABLE +Aid tbl-b +"\n\n +(TBODY +(TR +(TD +Aid td-b1 +)TD +)TR +"\n +)TBODY +)TABLE +"\n +)TD +)TR +"\n +)TBODY +)TABLE +"\n +)BODY +)HTML Modified: trunk/doc/changes.html =================================================================== --- trunk/doc/changes.html 2009-12-07 14:50:09 UTC (rev 270) +++ trunk/doc/changes.html 2009-12-14 19:53:07 UTC (rev 271) @@ -33,7 +33,8 @@ <code>TABLE</code> can have multiple <code>THEAD</code>, <code>TBODY</code> and <code>TFOOT</code> (patch provided by Ahmed Ashour, #2893796), trim encoding found in <code>meta</code> tag (#2904817), fix ArrayIndexOutOfBoundException on empty attribute when using feature <code>normalize-attrs</code>(#2838901), - recognize tags even if the <code>></code> of the opening tag is missing (#2886227) + recognize tags even if the <code>></code> of the opening tag is missing (#2886227), + only end <code>TABLE</code> can close a table (#2913095) </dd> <dt>Version 1.9.13 (2 Sept 2009) Modified: trunk/src/org/cyberneko/html/HTMLTagBalancer.java =================================================================== --- trunk/src/org/cyberneko/html/HTMLTagBalancer.java 2009-12-07 14:50:09 UTC (rev 270) +++ trunk/src/org/cyberneko/html/HTMLTagBalancer.java 2009-12-14 19:53:07 UTC (rev 271) @@ -1141,6 +1141,9 @@ */ protected final int getElementDepth(HTMLElements.Element element) { final boolean container = element.isContainer(); + final short elementCode = element.code; + final boolean tableBodyOrHtml = (elementCode == HTMLElements.TABLE) + || (elementCode == HTMLElements.BODY) || (elementCode == HTMLElements.HTML); int depth = -1; for (int i = fElementStack.top - 1; i >=fragmentContextStackSize_; i--) { Info info = fElementStack.data[i]; @@ -1151,6 +1154,9 @@ if (!container && info.element.isBlock()) { break; } + if (info.element.code == HTMLElements.TABLE && !tableBodyOrHtml) { + return -1; // current element not allowed to close a table + } } return depth; } // getElementDepth(HTMLElements.Element) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |