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 2010/04/28 15:41:53 UTC

svn commit: r938978 - /felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Util.java

Author: gnodet
Date: Wed Apr 28 13:41:53 2010
New Revision: 938978

URL: http://svn.apache.org/viewvc?rev=938978&view=rev
Log:
FELIX=2307: There is no way to bypass / escape property substitution

Modified:
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Util.java

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Util.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Util.java?rev=938978&r1=938977&r2=938978&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Util.java (original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/Util.java Wed Apr 28 13:41:53 2010
@@ -44,6 +44,7 @@ import org.osgi.service.log.LogService;
 
 public class Util
 {
+    private static final char   ESCAPE_CHAR = '\\';
     private static final String DELIM_START = "${";
     private static final String DELIM_STOP = "}";
 
@@ -106,6 +107,10 @@ public class Util
         // will correspond to the first deepest nested variable
         // placeholder.
         int stopDelim = val.indexOf(DELIM_STOP);
+        while (stopDelim > 0 && val.charAt(stopDelim - 1) == ESCAPE_CHAR)
+        {
+            stopDelim = val.indexOf(DELIM_STOP, stopDelim + 1);
+        }
 
         // Find the matching starting "${" variable delimiter
         // by looping until we find a start delimiter that is
@@ -166,6 +171,18 @@ public class Util
         // be substitutions to make.
         val = substVars(val, currentKey, cycleMap, configProps);
 
+        // Remove escape characters preceding {, } and \
+        int escape = val.indexOf(ESCAPE_CHAR);
+        while (escape >= 0 && escape < val.length() - 1)
+        {
+            char c = val.charAt(escape + 1);
+            if (c == '{' || c == '}' || c == ESCAPE_CHAR)
+            {
+                val = val.substring(0, escape) + val.substring(escape + 1);
+            }
+            escape = val.indexOf(ESCAPE_CHAR, escape + 1);
+        }
+
         // Return the value.
         return val;
     }