in velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java [212:240]
private String replaceQuotes(String s, char literalQuoteChar)
{
if( (literalQuoteChar == '"' && !s.contains("\"")) ||
(literalQuoteChar == '\'' && !s.contains("'")) )
{
return s;
}
StringBuilder result = new StringBuilder(s.length());
for(int i = 0, is = s.length(); i < is; i++)
{
char c = s.charAt(i);
result.append(c);
if( i + 1 < is )
{
char next = s.charAt(i + 1);
// '""' -> "", "''" -> ''
// thus it is not necessary to double quotes if the "surrounding" quotes
// of the StringLiteral are different. See VELOCITY-785
if( (literalQuoteChar == '"' && (next == '"' && c == '"')) ||
(literalQuoteChar == '\'' && (next == '\'' && c == '\'')) )
{
i++;
}
}
}
return result.toString();
}