[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
This commit is contained in:
Benjamin Bentmann 2010-04-07 13:44:18 +00:00
parent fc7636db41
commit 1f9e91da55
1 changed files with 15 additions and 0 deletions

View File

@ -38,6 +38,7 @@ import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.interpolation.EnvarBasedValueSource; import org.codehaus.plexus.interpolation.EnvarBasedValueSource;
import org.codehaus.plexus.interpolation.InterpolationException; import org.codehaus.plexus.interpolation.InterpolationException;
import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
import org.codehaus.plexus.interpolation.PropertiesBasedValueSource; import org.codehaus.plexus.interpolation.PropertiesBasedValueSource;
import org.codehaus.plexus.interpolation.RegexBasedInterpolator; import org.codehaus.plexus.interpolation.RegexBasedInterpolator;
@ -189,6 +190,20 @@ public class DefaultSettingsBuilder
+ e.getMessage(), -1, -1, e ); + 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( "&", "&amp;" ).replace( "<", "&lt;" ).replace( ">", "&gt;" );
return value;
}
return null;
}
} );
try try
{ {
serializedSettings = interpolator.interpolate( serializedSettings, "settings" ); serializedSettings = interpolator.interpolate( serializedSettings, "settings" );