Jochen Wiedmann wrote:

As he wrote, these characters are illegal, regardless of encoding,
CDATA, and so on. XML is a text format and ASCII 0 is a binary
character.

The suggested way to embed binary data into XML is using the base64 encoding.

Apart from that, I do not understand the use case. Where do we need to
embed binary data into XML?

When a test fails (by throwing a Throwable) Surefire needs to output the message string of the failure in the XML test result output; Java strings may contain the null character \u0000. Therefore, not all Java strings can be saved as XML, and so the task is impossible.

The trivial example is:

  junit.framework.Assert.fail("\u0000");

A more realistic example would be:

  String value = blah(); // returns \u0000
  junit.framework.Assert.assertEquals("", value);

My current best resolution for this is to deliberately double-encode these characters, so you'd see in the XML:

  <failure type="junit.framework.AssertionFailedError" message="&amp;#0;">

That's literally wrong, but I don't know of anything better to do. I've filed this as bug SUREFIRE-456, targeted for "Future" because I have no idea when/if we'd ever fix this.

-Dan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to