desruisseaux commented on code in PR #11426:
URL: https://github.com/apache/maven/pull/11426#discussion_r2538753399


##########
impl/maven-testing/src/main/java/org/apache/maven/api/plugin/testing/MojoExtension.java:
##########
@@ -269,7 +272,27 @@ public Object resolveParameter(ParameterContext 
parameterContext, ExtensionConte
                     .map(ConfigurationContainer::getConfiguration)
                     .orElseGet(() -> XmlNode.newInstance("config"));
             List<XmlNode> children = mojoParameters.stream()
-                    .map(mp -> XmlNode.newInstance(mp.name(), mp.value()))
+                    .map(mp -> {
+                        String s;
+                        if (mp.xml()) {
+                            // Parse as XML - value contains XML elements
+                            s = "<" + mp.name() + ">" + mp.value() + "</" + 
mp.name() + ">";
+                        } else {
+                            // Treat as plain text - escape XML special 
characters
+                            String escapedValue = mp.value()
+                                    .replace("&", "&amp;")
+                                    .replace("<", "&lt;")
+                                    .replace(">", "&gt;")
+                                    .replace("\"", "&quot;")
+                                    .replace("'", "&apos;");
+                            s = "<" + mp.name() + ">" + escapedValue + "</" + 
mp.name() + ">";
+                        }
+                        try {

Review Comment:
   It is a small details (not really important), but the code could be 
factorized a little bit:
   
   ```java
   String value = mp.value();
   if (!mp.xml()) {
       // Treat as plain text - escape XML special characters
       value = value
               .replace("&", "&amp;")
               .replace("<", "&lt;")
               .replace(">", "&gt;")
               .replace("\"", "&quot;")
               .replace("'", "&apos;");
   }
   String s = '<' + mp.name() + '>' + value + "</" + mp.name() + '>';
   ```
   
   I also replaced strings of 1 character by single characters.



-- 
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