[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/lexerTests LexerTests.java,1.25,1.26
Brought to you by:
derrickoswald
|
From: Derrick O. <der...@us...> - 2005-09-19 02:35:13
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/lexerTests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30508/src/org/htmlparser/tests/lexerTests Modified Files: LexerTests.java Log Message: Apply patch #1247128 Bug Fix: #1227213 Particular SCRIPT tags close too late from Keiron McCammon. Index: LexerTests.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/lexerTests/LexerTests.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** LexerTests.java 15 May 2005 11:49:05 -0000 1.25 --- LexerTests.java 19 Sep 2005 02:35:05 -0000 1.26 *************** *** 37,40 **** --- 37,42 ---- import org.htmlparser.Text; import org.htmlparser.lexer.Lexer; + import org.htmlparser.tags.ScriptTag; + import org.htmlparser.tags.StyleTag; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.EncodingChangeException; *************** *** 273,277 **** char[] test; ! URL url = new URL ("http://sourceforge.net/projects/htmlparser"); lexer = new Lexer (url.openConnection ()); position = 0; --- 275,279 ---- char[] test; ! URL url = new URL ("http://sourceforge.net"); lexer = new Lexer (url.openConnection ()); position = 0; *************** *** 836,839 **** --- 838,906 ---- } + /** + * See bug #1227213 Particular SCRIPT tags close too late. + */ + public void testCommentInScript () throws ParserException + { + String tag; + String cdata; + String endtag; + String html; + Parser parser; + NodeIterator iterator; + Node node; + + tag = "<script>"; + cdata = "<!--document.write(\"en\");// -->"; + endtag = "</script>"; + html = tag + cdata + endtag; + parser = new Parser (); + parser.setInputHTML (html); + iterator = parser.elements (); + node = iterator.nextNode (); + if (node == null) + fail ("too few nodes"); + else + assertStringEquals ("bad parse", html, node.toHtml()); + assertTrue (node instanceof ScriptTag); + assertStringEquals ("bad cdata", cdata, ((ScriptTag)node).getScriptCode ()); + assertNull ("too many nodes", iterator.nextNode ()); + } + + /** + * See bug #1227213 Particular SCRIPT tags close too late. + * This was actually working prior to the patch, since the + * ScriptScanner didn't use smartquote processing. + * I'm not sure why jwilsonsprings1 said the patch worked + * for him. I can only assume he was mistaken in thinking + * it was the URL that caused the failure. + */ + public void testUrlInStyle () throws ParserException + { + String tag; + String cdata; + String endtag; + String html; + Parser parser; + NodeIterator iterator; + Node node; + + tag = "<style>"; + cdata = ".eSDot {background-image:" + + "url(http://di.image.eshop.msn.com/img/sys/dot.gif)}"; + endtag = "</style>"; + html = tag + cdata + endtag; + parser = new Parser (); + parser.setInputHTML (html); + iterator = parser.elements (); + node = iterator.nextNode (); + if (node == null) + fail ("too few nodes"); + else + assertStringEquals ("bad parse", html, node.toHtml()); + assertTrue (node instanceof StyleTag); + assertStringEquals ("bad cdata", cdata, ((StyleTag)node).getStyleCode ()); + assertNull ("too many nodes", iterator.nextNode ()); + } } |