[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/scannersTests ScriptScannerTest.java,1.58,1.59
Brought to you by:
derrickoswald
From: Derrick O. <der...@us...> - 2005-03-12 17:53:21
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25217/tests/scannersTests Modified Files: ScriptScannerTest.java Log Message: Add STRICT flag to ScriptScanner to revert to legacy handling of broken ETAGO (</). If STRICT is true, scan according to HTML specification, else if false, scan with quote smart state machine which heuristically yields the correct parse. Index: ScriptScannerTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests/ScriptScannerTest.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** ScriptScannerTest.java 7 Mar 2005 02:18:47 -0000 1.58 --- ScriptScannerTest.java 12 Mar 2005 17:53:11 -0000 1.59 *************** *** 183,195 **** * string parser was not moving to the ignore state on encountering double * quotes (only single quotes were previously accepted). - * - * <pre> - * Bug #1104627 Parser Crash reading javascript - * Bug #1024045 StringBean crashes on an URL - * Bug #1021925 StyleTag with missing linefeed prevents page from parsing - * </pre> - * Altered test to correctly escape the ETAGO. - * See http://www.w3.org/TR/html4/appendix/notes.html#notes-specifying-data - * * @throws Exception */ --- 183,186 ---- *************** *** 212,216 **** "document.write(\"}\"); " + "// parser thinks this is the end tag.\n" + ! "document.write(\"<\\/script>\");" + "</script>" + "<body>" + --- 203,207 ---- "document.write(\"}\"); " + "// parser thinks this is the end tag.\n" + ! "document.write(\"</script>\");" + "</script>" + "<body>" + *************** *** 235,239 **** "document.write(\"}\"); " + "// parser thinks this is the end tag.\n" + ! "document.write(\"<\\/script>\");", scriptTag.getScriptCode() ); --- 226,230 ---- "document.write(\"}\"); " + "// parser thinks this is the end tag.\n" + ! "document.write(\"</script>\");", scriptTag.getScriptCode() ); *************** *** 241,260 **** } - /** - * - * <pre> - * Bug #1104627 Parser Crash reading javascript - * Bug #1024045 StringBean crashes on an URL - * Bug #1021925 StyleTag with missing linefeed prevents page from parsing - * </pre> - * Altered test to correctly escape the ETAGO. - * See http://www.w3.org/TR/html4/appendix/notes.html#notes-specifying-data - * - */ public void testScriptCodeExtraction() throws ParserException { createParser( "<SCRIPT language=JavaScript>" + "document.write(\"<a href=\"1.htm\"><img src=\"1.jpg\" " + ! "width=\"80\" height=\"20\" border=\"0\"><\\/a>\");" + "</SCRIPT>" ); --- 232,240 ---- } public void testScriptCodeExtraction() throws ParserException { createParser( "<SCRIPT language=JavaScript>" + "document.write(\"<a href=\"1.htm\"><img src=\"1.jpg\" " + ! "width=\"80\" height=\"20\" border=\"0\"></a>\");" + "</SCRIPT>" ); *************** *** 265,289 **** "script code", "document.write(\"<a href=\"1.htm\"><img src=\"1.jpg\" " + ! "width=\"80\" height=\"20\" border=\"0\"><\\/a>\");", scriptTag.getScriptCode() ); } - /** - * - * <pre> - * Bug #1104627 Parser Crash reading javascript - * Bug #1024045 StringBean crashes on an URL - * Bug #1021925 StyleTag with missing linefeed prevents page from parsing - * </pre> - * Altered test to correctly escape the ETAGO. - * See http://www.w3.org/TR/html4/appendix/notes.html#notes-specifying-data - * - */ public void testScriptCodeExtractionWithMultipleQuotes() throws ParserException { createParser( "<SCRIPT language=JavaScript>" + "document.write(\"<a href=\\\"1.htm\\\"><img src=\\\"1.jpg\\\" " + ! "width=\\\"80\\\" height=\\\"20\\\" border=\\\"0\\\"><\\/a>\");" + "</SCRIPT>" ); --- 245,258 ---- "script code", "document.write(\"<a href=\"1.htm\"><img src=\"1.jpg\" " + ! "width=\"80\" height=\"20\" border=\"0\"></a>\");", scriptTag.getScriptCode() ); } public void testScriptCodeExtractionWithMultipleQuotes() throws ParserException { createParser( "<SCRIPT language=JavaScript>" + "document.write(\"<a href=\\\"1.htm\\\"><img src=\\\"1.jpg\\\" " + ! "width=\\\"80\\\" height=\\\"20\\\" border=\\\"0\\\"></a>\");" + "</SCRIPT>" ); *************** *** 294,313 **** "script code", "document.write(\"<a href=\\\"1.htm\\\"><img src=\\\"1.jpg\\\" " + ! "width=\\\"80\\\" height=\\\"20\\\" border=\\\"0\\\"><\\/a>\");", scriptTag.getScriptCode() ); } - /** - * - * <pre> - * Bug #1104627 Parser Crash reading javascript - * Bug #1024045 StringBean crashes on an URL - * Bug #1021925 StyleTag with missing linefeed prevents page from parsing - * </pre> - * Altered test to correctly escape the ETAGO. - * See http://www.w3.org/TR/html4/appendix/notes.html#notes-specifying-data - * - */ public void testScriptWithinComments() throws Exception { createParser( --- 263,271 ---- "script code", "document.write(\"<a href=\\\"1.htm\\\"><img src=\\\"1.jpg\\\" " + ! "width=\\\"80\\\" height=\\\"20\\\" border=\\\"0\\\"></a>\");", scriptTag.getScriptCode() ); } public void testScriptWithinComments() throws Exception { createParser( *************** *** 350,354 **** "else{" + "\n" + ! "menuobj.document.write('<layer name=gui bgColor=#E6E6E6 width=165 onmouseover=\"clearhidemenu()\" onmouseout=\"hidemenu()\">'+which+'<\\/layer>')" + "\n" + "menuobj.document.close()" + --- 308,312 ---- "else{" + "\n" + ! "menuobj.document.write('<layer name=gui bgColor=#E6E6E6 width=165 onmouseover=\"clearhidemenu()\" onmouseout=\"hidemenu()\">'+which+'</layer>')" + "\n" + "menuobj.document.close()" + *************** *** 558,574 **** /** * See bug #741769 ScriptScanner doesn't handle quoted </script> tags - * - * <pre> - * Bug #1104627 Parser Crash reading javascript - * Bug #1024045 StringBean crashes on an URL - * Bug #1021925 StyleTag with missing linefeed prevents page from parsing - * </pre> - * Altered test to correctly escape the ETAGO. - * See http://www.w3.org/TR/html4/appendix/notes.html#notes-specifying-data - * */ public void testScanQuotedEndTag() throws ParserException { ! String html = "<SCRIPT language=\"JavaScript\">document.write('<\\/SCRIPT>');</SCRIPT>"; createParser(html); parseAndAssertNodeCount(1); --- 516,523 ---- /** * See bug #741769 ScriptScanner doesn't handle quoted </script> tags */ public void testScanQuotedEndTag() throws ParserException { ! String html = "<SCRIPT language=\"JavaScript\">document.write('</SCRIPT>');</SCRIPT>"; createParser(html); parseAndAssertNodeCount(1); |