azotcsit commented on a change in pull request #175:
URL: https://github.com/apache/ant/pull/175#discussion_r791701322



##########
File path: 
src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LegacyXmlResultFormatter.java
##########
@@ -298,8 +298,9 @@ private void writeFailed(final XMLStreamWriter writer, 
final TestIdentifier test
                     writeAttribute(writer, ATTR_MESSAGE, message);
                 }
                 writeAttribute(writer, ATTR_TYPE, t.getClass().getName());
-                // write out the stacktrace
-                writer.writeCData(StringUtils.getStackTrace(t));
+                // write out the stacktrace, replacing any CDATA endings by 
splitting them into multiple CDATA segments
+                // See https://bz.apache.org/bugzilla/show_bug.cgi?id=65833
+                
writer.writeCData(StringUtils.getStackTrace(t).replaceAll("]]>", 
"]]]]><![CDATA[>"));

Review comment:
       Ok, thanks for the details! Originally I was not clear why splitting 
CDATA section is better than escaping. But looks like it is a common practice 
for nesting CDATA sections [1]. Moreover, _junit_ team fixed such an issue in 
the same way [2]. The fix looks good to me!
   
   [1] https://en.wikipedia.org/wiki/CDATA#Nesting
   [2] https://github.com/junit-team/junit5/issues/1225
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
For additional commands, e-mail: dev-h...@ant.apache.org

Reply via email to