[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/scannersTests ScriptScannerTest.java,1.22,1.23
Brought to you by:
derrickoswald
From: <der...@us...> - 2003-05-24 21:04:48
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests In directory sc8-pr-cvs1:/tmp/cvs-serv7741/org/htmlparser/tests/scannersTests Modified Files: ScriptScannerTest.java Log Message: Fixed bug #741769 ScriptScanner doesn't handle quoted </script> tags Major overhaul of ScriptScanner. It now uses the scan() method of CompositeTagScanner (i.e. doesn't override). CompositeTagScanner now has a balance_quotes member field that dictates whether strings tags are scanned honouring single and double quotes. This affected the call chain through NodeReader and StringScanner which now have this parameter. StringScanner now correctly handles quotes if asked. The ignoreState stuff is removed, it didn't work anyway since a single StringScanner is used recursively by the NodeReader, and the member field would have been tromped. Sorry to all those who have broken code because of this, but it's for the better. Really. Index: ScriptScannerTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests/ScriptScannerTest.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ScriptScannerTest.java 19 May 2003 02:49:59 -0000 1.22 --- ScriptScannerTest.java 24 May 2003 21:04:45 -0000 1.23 *************** *** 117,121 **** StringBuffer sb2 = new StringBuffer(); ! sb2.append("\r\nif(navigator.appName.indexOf(\"Netscape\") != -1)\r\n"); sb2.append(" document.write ('xxx');\r\n"); sb2.append("else\r\n"); --- 117,121 ---- StringBuffer sb2 = new StringBuffer(); ! sb2.append("if(navigator.appName.indexOf(\"Netscape\") != -1)\r\n"); sb2.append(" document.write ('xxx');\r\n"); sb2.append("else\r\n"); *************** *** 127,131 **** // Check the data in the applet tag ScriptTag scriptTag = (ScriptTag)node[1]; ! assertStringEquals("Expected Script Code",testHTML2,scriptTag.getScriptCode()); } --- 127,132 ---- // Check the data in the applet tag ScriptTag scriptTag = (ScriptTag)node[1]; ! String s = scriptTag.getScriptCode(); ! assertStringEquals("Expected Script Code",testHTML2,s); } *************** *** 171,175 **** ScriptTag scriptTag = (ScriptTag)node[0]; String scriptCode = scriptTag.getScriptCode(); ! String expectedCode = "\r\n<!--\r\n"+ " function validateForm()\r\n"+ " {\r\n"+ --- 172,176 ---- ScriptTag scriptTag = (ScriptTag)node[0]; String scriptCode = scriptTag.getScriptCode(); ! String expectedCode = "<!--\r\n"+ " function validateForm()\r\n"+ " {\r\n"+ *************** *** 179,183 **** " return true;\r\n"+ " }\r\n"+ ! "// -->\r\n"; assertStringEquals("Expected Code",expectedCode,scriptCode); } --- 180,184 ---- " return true;\r\n"+ " }\r\n"+ ! "// -->"; assertStringEquals("Expected Code",expectedCode,scriptCode); } *************** *** 545,548 **** parseAndAssertNodeCount(1); } ! } --- 546,559 ---- parseAndAssertNodeCount(1); } ! ! /** ! * See bug #741769 ScriptScanner doesn't handle quoted </script> tags ! */ ! public void testScanQuotedEndTag() throws ParserException { ! createParser("<SCRIPT language=\"JavaScript\">document.write('</SCRIPT>');</SCRIPT>"); ! parser.addScanner(new ScriptScanner("-s")); ! parseAndAssertNodeCount(1); ! String s = node[0].toHtml (); ! assertEquals ("Parse error","<SCRIPT LANGUAGE=\"JavaScript\">document.write('</SCRIPT>');</SCRIPT>",s); ! } } |