Copilot commented on code in PR #3408:
URL: https://github.com/apache/maven-surefire/pull/3408#discussion_r3773113821


##########
maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java:
##########
@@ -276,6 +276,90 @@ public void testAllFieldsSerialized() throws IOException {
                 tcb.getChild("system-err").getValue());
     }
 
+    @Test
+    public void testInvalidXml10CharactersAreEscaped() throws Exception {
+        String supplementaryCharacter = new String(Character.toChars(0x1F600));
+        StackTraceWriter stackTraceWriter = new DeserializedStacktraceWriter(
+                "failure\uFFFF",
+                "trimmed " + supplementaryCharacter,
+                "stack trace\uFFFE\uFFFF " + supplementaryCharacter);
+
+        Utf8RecodingDeferredFileOutputStream stdOut = new 
Utf8RecodingDeferredFileOutputStream("fds");
+        StringBuilder stdout = new 
StringBuilder(Utf8RecodingDeferredFileOutputStream.CACHE_SIZE + 16);
+        for (int i = 0; i < Utf8RecodingDeferredFileOutputStream.CACHE_SIZE - 
1; i++) {
+            stdout.append('a');
+        }
+        stdout.append('\uFFFF').append(" ]]> ");
+        stdOut.write(stdout.toString(), false, null);

Review Comment:
   This does not exercise the new malformed UTF-8 handling: `write(String, 
...)` encodes through `String.getBytes(UTF_8)`, so the decoder always receives 
well-formed UTF-8. The invalid-leading-byte, invalid-continuation, and 
incomplete-sequence branches therefore remain untested despite the PR's stated 
malformed-sequence coverage. Please add raw-byte tests for these cases, 
including a sequence split across writes, and assert that the resulting XML 
parses and contains U+FFFD.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to