diff --git a/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoHtmlParser.java b/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoHtmlParser.java index a571a08524..74b464f238 100644 --- a/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoHtmlParser.java +++ b/src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoHtmlParser.java @@ -180,6 +180,7 @@ public void parse(final WebResponse webResponse, final HtmlPage page, domBuilder.setFeature(HTMLScanner.ALLOW_SELFCLOSING_TAGS, true); domBuilder.setFeature(HTMLScanner.SCRIPT_STRIP_CDATA_DELIMS, true); domBuilder.setFeature(HTMLScanner.STYLE_STRIP_CDATA_DELIMS, true); + domBuilder.setFeature(HTMLScanner.CDATA_EARLY_CLOSING, false); } } catch (final Exception e) { diff --git a/src/test/java/org/htmlunit/html/XHtmlPage2Test.java b/src/test/java/org/htmlunit/html/XHtmlPage2Test.java index 21c7f1c57c..02a45eb281 100644 --- a/src/test/java/org/htmlunit/html/XHtmlPage2Test.java +++ b/src/test/java/org/htmlunit/html/XHtmlPage2Test.java @@ -19,6 +19,7 @@ import org.htmlunit.WebDriverTestCase; import org.htmlunit.junit.BrowserRunner; import org.htmlunit.junit.BrowserRunner.Alerts; +import org.htmlunit.junit.BrowserRunner.HtmlUnitNYI; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.By; @@ -83,4 +84,100 @@ public void selfClosingTextarea() throws Exception { assertEquals("", driver.findElement(By.id("myText")).getText()); } + + /** + * Regression test for Bug #1219. + * + * @throws Exception if an error occurs + */ + @Test + @Alerts({"beforeafter", + "
beforeafter
", + "beforeinsideafter"}) + @HtmlUnitNYI(CHROME = {"beforeafter", + "
beforeafter
", + "beforeinsideafter"}, + EDGE = {"beforeafter", + "
beforeafter
", + "beforeinsideafter"}, + FF = {"beforeafter", + "
beforeafter
", + "beforeinsideafter"}, + FF_ESR = {"beforeafter", + "
beforeafter
", + "beforeinsideafter"}) + public void cdata() throws Exception { + final String html + = "\n" + + "\n" + + "\n" + + "" + + " \n" + + "" + + "\n" + + "
beforeafter
\n" + + "\n" + + ""; + + final WebDriver driver = loadPage2(html, URL_FIRST, "application/xhtml+xml", ISO_8859_1); + assertEquals("beforeafter", driver.findElement(By.id("tester")).getText()); + verifyTitle2(driver, getExpectedAlerts()); + } + + /** + * Regression test for Bug #1219. + * + * @throws Exception if an error occurs + */ + @Test + @Alerts({"before]]>after", + "
before
]]>after", + "before
after"}) + @HtmlUnitNYI(CHROME = {"beforeafter", + "
beforeafter
", + "beforeafter"}, + EDGE = {"beforeafter", + "
beforeafter
", + "beforeafter"}, + FF = {"beforeafter", + "
beforeafter
", + "beforeafter"}, + FF_ESR = {"beforeafter", + "
beforeafter
", + "beforeafter"}) + public void earlyClosingCdata() throws Exception { + final String html + = "\n" + + "\n" + + "\n" + + "" + + " \n" + + "" + + "\n" + + "
before
]]>after\n" + + "\n" + + ""; + + final WebDriver driver = loadPage2(html, URL_FIRST, "application/xhtml+xml", ISO_8859_1); + assertEquals("beforeafter", driver.findElement(By.id("tester")).getText()); + verifyTitle2(driver, getExpectedAlerts()); + } }