Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,17 @@ private String interpolate( String input, RecursionInterceptor recursionIntercep

if ( startIdx >= 0 && escapeString != null && escapeString.length() > 0 )
{
int startEscapeIdx = startIdx == 0 ? 0 : startIdx - escapeString.length();
int startEscapeIdx = ( startIdx == 0 ) ? 0 : startIdx - escapeString.length();
if ( startEscapeIdx >= 0 )
{
String escape = input.substring( startEscapeIdx, startIdx );
if ( escape != null && escapeString.equals( escape ) )
{
result.append( wholeExpr );
if ( startEscapeIdx > 0 )
{
--startEscapeIdx;
}
result.replace( startEscapeIdx, startEscapeIdx + escapeString.length(), "" );
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,22 @@ public void testInterpolationWithMultipleEscapes()
assertEquals( "#${first} and ${last}", result );
}

public void testInterpolationWithMultipleEscapes2()
throws InterpolationException
{
Map ctx = new HashMap();
ctx.put( "name", "User" );
ctx.put( "otherName", "#${first} and ##${last}" );

String input = "${otherName}";

ValueSource vs = new MapBasedValueSource( ctx );
MultiDelimiterStringSearchInterpolator interpolator =
new MultiDelimiterStringSearchInterpolator().withValueSource( vs );
interpolator.setEscapeString( "#" );

String result = interpolator.interpolate( input );

assertEquals( "${first} and #${last}", result );
}
}