Skip to content

Commit 5c2080c

Browse files
committed
Issue #124 - Split CDATA sections causing trouble in JDOM 1.x. Add test case to 2.x anyway - even though code works.
1 parent e252be9 commit 5c2080c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/src/java/org/jdom2/test/cases/input/TestSAXBuilder.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,19 @@ public void testBuildStringNegativePaddedXML() {
11201120
}
11211121
}
11221122

1123+
@Test
1124+
public void testSplitCDATAinCDATA() throws JDOMException, IOException {
1125+
// Note the ]]><![CDATA[ in the middle
1126+
String toparse = "<message><![CDATA[ expected:<[[D/0]]]]><![CDATA[> but was:<[null]> ]]></message>";
1127+
1128+
SAXBuilder sb = new SAXBuilder();
1129+
Document doc = sb.build(new CharArrayReader(toparse.toCharArray()));
1130+
1131+
assertEquals("Should match: expected:<[[D/0]]> but was:<[null]>", " expected:<[[D/0]]> but was:<[null]> " , doc.getRootElement().getValue());
1132+
1133+
1134+
}
1135+
11231136
@Test
11241137
public void testParserFactory() throws JDOMException, IOException {
11251138
if (System.getProperty("org.jdom2.performance") == null) {

0 commit comments

Comments
 (0)