From 1f9e91da55a4d6a0314eda7dd5ae4500999adb3d Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Wed, 7 Apr 2010 13:44:18 +0000 Subject: [PATCH] [MNG-4625] Interpolation of settings.xml fails if an expression's value contains XML markup git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@931545 13f79535-47bb-0310-9956-ffa450edef68 --- .../settings/building/DefaultSettingsBuilder.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/maven-core/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuilder.java b/maven-core/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuilder.java index e5fdee9655..3620d5bb9e 100644 --- a/maven-core/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuilder.java @@ -38,6 +38,7 @@ import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.interpolation.EnvarBasedValueSource; import org.codehaus.plexus.interpolation.InterpolationException; +import org.codehaus.plexus.interpolation.InterpolationPostProcessor; import org.codehaus.plexus.interpolation.PropertiesBasedValueSource; import org.codehaus.plexus.interpolation.RegexBasedInterpolator; @@ -189,6 +190,20 @@ public class DefaultSettingsBuilder + e.getMessage(), -1, -1, e ); } + interpolator.addPostProcessor( new InterpolationPostProcessor() + { + public Object execute( String expression, Object value ) + { + if ( value != null ) + { + // we're going to parse this back in as XML so we need to escape XML markup + value = value.toString().replace( "&", "&" ).replace( "<", "<" ).replace( ">", ">" ); + return value; + } + return null; + } + } ); + try { serializedSettings = interpolator.interpolate( serializedSettings, "settings" );