git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@955226 13f79535-47bb-0310-9956-ffa450edef68master
@@ -20,6 +20,9 @@ Changes that could break older environments: | |||||
ampersands so that { remained { rather than being turned | ampersands so that { remained { rather than being turned | ||||
into {. This is no longer the case, ampersands will now | into {. This is no longer the case, ampersands will now | ||||
be encoded unconditionally. | be encoded unconditionally. | ||||
Also DOMElementWriter#encodeData will treat CDATA sections containing a | |||||
literal "]]>" sequence different now - it will split the CDATA | |||||
section between the second "]" and ">" and create two sections. | |||||
This affects <echoxml> task as well as the XML logger or JUnit | This affects <echoxml> task as well as the XML logger or JUnit | ||||
formatter where ampersands will now always get encoded. | formatter where ampersands will now always get encoded. | ||||
Bugzilla Report 49404. | Bugzilla Report 49404. | ||||
@@ -467,19 +467,7 @@ public class DOMElementWriter { | |||||
} | } | ||||
} | } | ||||
String result = sb.substring(0); | |||||
int cdEnd = result.indexOf("]]>"); | |||||
while (cdEnd != -1) { | |||||
sb.setLength(cdEnd); | |||||
// CheckStyle:MagicNumber OFF | |||||
sb.append("]]>") | |||||
.append(result.substring(cdEnd + 3)); | |||||
// CheckStyle:MagicNumber ON | |||||
result = sb.substring(0); | |||||
cdEnd = result.indexOf("]]>"); | |||||
} | |||||
return result; | |||||
return sb.toString().replace("]]>", "]]]]><![CDATA[>"); | |||||
} | } | ||||
/** | /** | ||||
@@ -90,11 +90,11 @@ public class DOMElementWriterTest extends TestCase { | |||||
public void testCDATAEndEncoding() { | public void testCDATAEndEncoding() { | ||||
assertEquals("]>", w.encodedata("]>")); | assertEquals("]>", w.encodedata("]>")); | ||||
assertEquals("]]", w.encodedata("]]")); | assertEquals("]]", w.encodedata("]]")); | ||||
assertEquals("]]>", w.encodedata("]]>")); | |||||
assertEquals("]]>A", w.encodedata("]]>A")); | |||||
assertEquals("A]]>", w.encodedata("A]]>")); | |||||
assertEquals("A]]>A", w.encodedata("A]]>A")); | |||||
assertEquals("A]]>B]]>C", | |||||
assertEquals("]]]]><![CDATA[>", w.encodedata("]]>")); | |||||
assertEquals("]]]]><![CDATA[>A", w.encodedata("]]>A")); | |||||
assertEquals("A]]]]><![CDATA[>", w.encodedata("A]]>")); | |||||
assertEquals("A]]]]><![CDATA[>A", w.encodedata("A]]>A")); | |||||
assertEquals("A]]]]><![CDATA[>B]]]]><![CDATA[>C", | |||||
w.encodedata("A]]>B]]>C")); | w.encodedata("A]]>B]]>C")); | ||||
} | } | ||||