desruisseaux commented on code in PR #11426:
URL: https://github.com/apache/maven/pull/11426#discussion_r2539678998
##########
impl/maven-testing/src/main/java/org/apache/maven/api/plugin/testing/MojoExtension.java:
##########
@@ -273,24 +273,20 @@ public Object resolveParameter(ParameterContext
parameterContext, ExtensionConte
.orElseGet(() -> XmlNode.newInstance("config"));
List<XmlNode> children = mojoParameters.stream()
.map(mp -> {
- String s;
- if (mp.xml()) {
- // Parse as XML - value contains XML elements
- s = "<" + mp.name() + ">" + mp.value() + "</" +
mp.name() + ">";
- } else {
+ String value = mp.value();
+ if (!mp.xml()) {
// Treat as plain text - escape XML special
characters
- String escapedValue = mp.value()
- .replace("&", "&")
+ value = value.replace("&", "&")
.replace("<", "<")
.replace(">", ">")
.replace("\"", """)
.replace("'", "'");
- s = "<" + mp.name() + ">" + escapedValue + "</" +
mp.name() + ">";
}
+ String s = '<' + mp.name() + '>' + value + "</" +
mp.name() + '>';
try {
return XmlService.read(new StringReader(s));
} catch (XMLStreamException e) {
- throw new MavenException("Unable to parse xml: " +
e.toString() + "\n" + s, e);
+ throw new MavenException("Unable to parse xml: " +
e + "\n" + s, e);
Review Comment:
Should we replace `"\n"` by `System.lineSeparator()`?
--
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]