From: <mgu...@us...> - 2008-08-26 08:03:49
|
Revision: 187 http://nekohtml.svn.sourceforge.net/nekohtml/?rev=187&view=rev Author: mguillem Date: 2008-08-26 08:03:58 +0000 (Tue, 26 Aug 2008) Log Message: ----------- Fixed bugs #2059466 and #2051091 (accepting unknown tags within inline elements as well as as containers, don't accept any container in head) Modified Paths: -------------- trunk/doc/changes.html trunk/src/org/cyberneko/html/HTMLElements.java trunk/src/org/cyberneko/html/HTMLTagBalancer.java Added Paths: ----------- trunk/data/canonical/test-unknown-element-head.html trunk/data/canonical/test-unknown-element.html trunk/data/test-unknown-element-head.html trunk/data/test-unknown-element.html Added: trunk/data/canonical/test-unknown-element-head.html =================================================================== --- trunk/data/canonical/test-unknown-element-head.html (rev 0) +++ trunk/data/canonical/test-unknown-element-head.html 2008-08-26 08:03:58 UTC (rev 187) @@ -0,0 +1,14 @@ +(HTML +(HEAD +(UNKNOWN1 +)UNKNOWN1 +(TITLE +"foo +)TITLE +(UNKNOWN2 +)UNKNOWN2 +(UNKNOWN3 +)UNKNOWN3 +)HEAD +"\n +)HTML Property changes on: trunk/data/canonical/test-unknown-element-head.html ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/data/canonical/test-unknown-element.html =================================================================== --- trunk/data/canonical/test-unknown-element.html (rev 0) +++ trunk/data/canonical/test-unknown-element.html 2008-08-26 08:03:58 UTC (rev 187) @@ -0,0 +1,59 @@ +(HTML +(HEAD +(TITLE +"foo +)TITLE +)HEAD +"\n +(BODY +"\n +(A +"Here is an +(UNKNOWN +"unknown element +)UNKNOWN +" in some inline text +)A +"\n +(DIV +"and +(UNKNOWN +"here +)UNKNOWN +" in some block text +)DIV +"\n +(P +"and +(UNKNOWN +"here +)UNKNOWN +" in a paragraph +)P +"\n\n +(UNKNOWN +"\n +(P +"containing p tag +)P +"\n +)UNKNOWN +"\n +(UNKNOWN +"\n +(A +"a tag +)A +"\n +)UNKNOWN +"\n +(UNKNOWN +"\n +(DIV +"and a div +)DIV +"\n +)UNKNOWN +"\n +)BODY +)HTML Property changes on: trunk/data/canonical/test-unknown-element.html ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/data/test-unknown-element-head.html =================================================================== --- trunk/data/test-unknown-element-head.html (rev 0) +++ trunk/data/test-unknown-element-head.html 2008-08-26 08:03:58 UTC (rev 187) @@ -0,0 +1 @@ +<html><head><unknown1><title>foo</title><unknown2><unknown3/></head> Property changes on: trunk/data/test-unknown-element-head.html ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/data/test-unknown-element.html =================================================================== --- trunk/data/test-unknown-element.html (rev 0) +++ trunk/data/test-unknown-element.html 2008-08-26 08:03:58 UTC (rev 187) @@ -0,0 +1,16 @@ +<html><head><title>foo</head> +<body> +<a>Here is an <unknown>unknown element</unknown> in some inline text</a> +<div>and <unknown>here</unknown> in some block text</div> +<p>and <unknown>here</unknown> in a paragraph</p> + +<unknown> +<p>containing p tag</p> +</unknown> +<unknown> +<a>a tag</a> +</unknown> +<unknown> +<div>and a div</div> +</unknown> +</body></html> \ No newline at end of file Property changes on: trunk/data/test-unknown-element.html ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/doc/changes.html =================================================================== --- trunk/doc/changes.html 2008-07-22 15:13:18 UTC (rev 186) +++ trunk/doc/changes.html 2008-08-26 08:03:58 UTC (rev 187) @@ -24,6 +24,9 @@ <h2>Releases</h2> <dl> + <dt>Future version + <dd>Fixed bugs #2059466 and #2051091 (accepting unknown tags within inline elements as well as as containers, don't accept any container in head) + <dt>Version 1.9.8 (22 Jul 2008) <dd>Fixed bugs #1949460 (handling of uppercase 'X' for entities in hexadecimal format), #1951703 (isEncodingCompatible throws UnsupportedOperationException when default encoding is JISAutoDetect, patch from Tatsuhiko Miyabe), Modified: trunk/src/org/cyberneko/html/HTMLElements.java =================================================================== --- trunk/src/org/cyberneko/html/HTMLElements.java 2008-07-22 15:13:18 UTC (rev 186) +++ trunk/src/org/cyberneko/html/HTMLElements.java 2008-08-26 08:03:58 UTC (rev 187) @@ -164,7 +164,7 @@ protected static final ElementList ELEMENTS = new ElementList(); /** No such element. */ - public static final Element NO_SUCH_ELEMENT = new Element(UNKNOWN, "", 0, new short[]{HEAD,BODY}/*HTML*/, null); + public static final Element NO_SUCH_ELEMENT = new Element(UNKNOWN, "", Element.BLOCK, new short[]{HEAD,BODY}/*HTML*/, null); // // Static initializer Modified: trunk/src/org/cyberneko/html/HTMLTagBalancer.java =================================================================== --- trunk/src/org/cyberneko/html/HTMLTagBalancer.java 2008-07-22 15:13:18 UTC (rev 186) +++ trunk/src/org/cyberneko/html/HTMLTagBalancer.java 2008-08-26 08:03:58 UTC (rev 187) @@ -556,10 +556,11 @@ } // close previous elements - // all elements close a <script> and an unknown element - if (fElementStack.top > 1 - && (fElementStack.peek().element.code == HTMLElements.SCRIPT - || fElementStack.peek().element == HTMLElements.NO_SUCH_ELEMENT)) { + // all elements close a <script> + // in head, no element has children + if ((fElementStack.top > 1 + && (fElementStack.peek().element.code == HTMLElements.SCRIPT)) + || fElementStack.top > 2 && fElementStack.data[fElementStack.top-2].element.code == HTMLElements.HEAD) { final Info info = fElementStack.pop(); if (fDocumentHandler != null) { callEndElement(info.qname, synthesizedAugs()); @@ -646,9 +647,9 @@ public void emptyElement(final QName element, XMLAttributes attrs, Augmentations augs) throws XNIException { startElement(element, attrs, augs); - // browser ignore the closing indication for non empty tags like <form .../> + // browser ignore the closing indication for non empty tags like <form .../> but not for unknown element final HTMLElements.Element elem = getElement(element.rawname); - if (elem.isEmpty()) { + if (elem.isEmpty() || elem.code == HTMLElements.UNKNOWN) { endElement(element, augs); } } // emptyElement(QName,XMLAttributes,Augmentations) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |