You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by gn...@apache.org on 2013/12/05 15:49:34 UTC
svn commit: r1548158 - in /felix/trunk/utils/src:
main/java/org/apache/felix/utils/properties/InterpolationHelper.java
test/java/org/apache/felix/utils/properties/InterpolationHelperTest.java
Author: gnodet
Date: Thu Dec 5 14:49:34 2013
New Revision: 1548158
URL: http://svn.apache.org/r1548158
Log:
[FELIX-4339] Make the use of escape characters deterministic
Modified:
felix/trunk/utils/src/main/java/org/apache/felix/utils/properties/InterpolationHelper.java
felix/trunk/utils/src/test/java/org/apache/felix/utils/properties/InterpolationHelperTest.java
Modified: felix/trunk/utils/src/main/java/org/apache/felix/utils/properties/InterpolationHelper.java
URL: http://svn.apache.org/viewvc/felix/trunk/utils/src/main/java/org/apache/felix/utils/properties/InterpolationHelper.java?rev=1548158&r1=1548157&r2=1548158&view=diff
==============================================================================
--- felix/trunk/utils/src/main/java/org/apache/felix/utils/properties/InterpolationHelper.java (original)
+++ felix/trunk/utils/src/main/java/org/apache/felix/utils/properties/InterpolationHelper.java Thu Dec 5 14:49:34 2013
@@ -146,6 +146,16 @@ public class InterpolationHelper {
SubstitutionCallback callback)
throws IllegalArgumentException
{
+ return unescape(doSubstVars(val, currentKey, cycleMap, configProps, callback));
+ }
+
+ private static String doSubstVars(String val,
+ String currentKey,
+ Map<String,String> cycleMap,
+ Map<String,String> configProps,
+ SubstitutionCallback callback)
+ throws IllegalArgumentException
+ {
if (cycleMap == null)
{
cycleMap = new HashMap<String,String>();
@@ -187,7 +197,7 @@ public class InterpolationHelper {
// return the existing value.
if ((startDelim < 0) || (stopDelim < 0))
{
- return unescape(val);
+ return val;
}
// At this point, we have found a variable placeholder so
@@ -236,10 +246,7 @@ public class InterpolationHelper {
// Now perform substitution again, since there could still
// be substitutions to make.
- val = substVars(val, currentKey, cycleMap, configProps, callback);
-
- // Remove escape characters preceding {, } and \
- val = unescape(val);
+ val = doSubstVars(val, currentKey, cycleMap, configProps, callback);
// Return the value.
return val;
Modified: felix/trunk/utils/src/test/java/org/apache/felix/utils/properties/InterpolationHelperTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/utils/src/test/java/org/apache/felix/utils/properties/InterpolationHelperTest.java?rev=1548158&r1=1548157&r2=1548158&view=diff
==============================================================================
--- felix/trunk/utils/src/test/java/org/apache/felix/utils/properties/InterpolationHelperTest.java (original)
+++ felix/trunk/utils/src/test/java/org/apache/felix/utils/properties/InterpolationHelperTest.java Thu Dec 5 14:49:34 2013
@@ -144,4 +144,17 @@ public class InterpolationHelperTest ext
assertEquals(map1, map2);
}
+ public void testMultipleEscapes()
+ {
+ LinkedHashMap<String, String> map1 = new LinkedHashMap<String, String>();
+ map1.put("a", "$\\\\{var}");
+ map1.put("abc", "${ab}c");
+ map1.put("ab", "${a}b");
+ InterpolationHelper.performSubstitution(map1);
+
+ assertEquals("$\\{var}", map1.get("a"));
+ assertEquals("$\\{var}b", map1.get("ab"));
+ assertEquals("$\\{var}bc", map1.get("abc"));
+ }
+
}