From: <asa...@us...> - 2013-10-07 17:14:17
|
Revision: 8608 http://sourceforge.net/p/htmlunit/code/8608 Author: asashour Date: 2013-10-07 17:14:14 +0000 (Mon, 07 Oct 2013) Log Message: ----------- IEConditionalCompilationScriptPreProcessor fix when evaluated to false. Issue 1502 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLParser2Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-10-06 16:01:38 UTC (rev 8607) +++ trunk/htmlunit/src/changes/changes.xml 2013-10-07 17:14:14 UTC (rev 8608) @@ -8,6 +8,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> + <action type="fix" dev="asashour" issue="1502"> + IEConditionalCompilationScriptPreProcessor fix when evaluated to false. + </action> <action type="add" dev="asashour" issue="1538"> JavaScript: add SVGSVGElement.createSVGRect(). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2013-10-06 16:01:38 UTC (rev 8607) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2013-10-07 17:14:14 UTC (rev 8608) @@ -962,13 +962,6 @@ protected void scanComment() throws IOException { final String s = nextContent(30); // [if ... if (s.startsWith("[if ") && s.contains("]>")) { - String commentTill = null; - if (s.contains("]><!-->")) { - commentTill = "<![endif]-->"; - } - else if (s.contains("]>-->")) { - commentTill = "<!--<![endif]-->"; - } final String condition = StringUtils.substringBefore(s.substring(4), "]>"); try { if (IEConditionalCommentExpressionEvaluator.evaluate(condition, browserVersion_)) { @@ -982,21 +975,14 @@ else if (s.contains("]>-->")) { skip("-->", false); } - return; } - if (commentTill != null) { - final XMLStringBuffer buffer = new XMLStringBuffer(); - int ch; - while ((ch = read()) != -1) { - buffer.append((char) ch); - if (buffer.toString().endsWith(commentTill)) { - final XMLStringBuffer trimmedBuffer - = new XMLStringBuffer(buffer.ch, 0, buffer.length - 3); - fDocumentHandler.comment(trimmedBuffer, locationAugs()); - return; - } + else { + final StringBuilder builder = new StringBuilder(); + while (!builder.toString().endsWith("-->")) { + builder.append((char) read()); } } + return; } catch (final Exception e) { // incorrect expression => handle it as plain text // TODO: report it! Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLParser2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLParser2Test.java 2013-10-06 16:01:38 UTC (rev 8607) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLParser2Test.java 2013-10-07 17:14:14 UTC (rev 8608) @@ -1553,7 +1553,7 @@ @Alerts(DEFAULT = { "<!--[if gt IE 11]><br><![endif]-->", "<!--[if lt IE 11]><br><![endif]-->" }, IE6 = { "", "<BR>" }, IE8 = { "", "<BR>" }) - @NotYetImplemented({ IE6, IE8 }) + @NotYetImplemented(IE6) public void ieConditionalCommentsNotInDom() throws Exception { final String html = "<html><head>\n" + "<script>\n" |