[FELIX-3396] Fix more cases, patch from Forrest Xia

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1301355 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java b/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
index c00c745..1e27b9a 100644
--- a/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
+++ b/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
@@ -320,10 +320,7 @@
 
     Configuration findExistingConfiguration(String fileName) throws Exception
     {
-        // escape the special character in the filename
-        fileName = fileName.replace("(", "\\(");
-        fileName = fileName.replace(")", "\\)");
-        String filter = "(" + DirectoryWatcher.FILENAME + "=" + fileName + ")";
+        String filter = "(" + DirectoryWatcher.FILENAME + "=" + escapeFilterValue(fileName) + ")";
         Configuration[] configurations = getConfigurationAdmin().listConfigurations(filter);
         if (configurations != null && configurations.length > 0)
         {
@@ -335,4 +332,11 @@
         }
     }
 
+    private String escapeFilterValue(String s) {
+        return s.replaceAll("[(]", "\\\\(").
+                replaceAll("[)]", "\\\\)").
+                replaceAll("[=]", "\\\\=").
+                replaceAll("[\\*]", "\\\\*");
+    }
+
 }