This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag 
org.apache.sling.installer.factory.configuration-1.0.10
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-factory-configuration.git

commit 380293d97c0aebd20d84376d67e23435399f6a88
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Fri Oct 5 12:03:02 2012 +0000

    FELIX-2578 :  Filter value should be escaped
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/trunk/installer/factories/configuration@1394467
 13f79535-47bb-0310-9956-ffa450edef68
---
 .../factories/configuration/impl/ConfigUtil.java     | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtil.java
 
b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtil.java
index 552345c..43e4826 100644
--- 
a/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtil.java
+++ 
b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtil.java
@@ -120,18 +120,28 @@ abstract class ConfigUtil {
         return cleanedConfig;
     }
 
+    /**
+     * Encode the value for the ldap filter: \, *, (, and ) should be escaped.
+     */
+    private static String encode(final String value) {
+        return value.replace("\\", "\\\\")
+                .replace("*", "\\*")
+                .replace("(", "\\(")
+                .replace(")", "\\)");
+    }
+
     public static Configuration getConfiguration(final ConfigurationAdmin ca,
             final String factoryPid,
             final String configPid,
             final boolean createIfNeeded)
-    throws IOException, InvalidSyntaxException {
+                    throws IOException, InvalidSyntaxException {
         Configuration result = null;
 
         if (factoryPid == null) {
             if (createIfNeeded) {
                 result = ca.getConfiguration(configPid, null);
             } else {
-                String filter = "(" + Constants.SERVICE_PID + "=" + configPid
+                String filter = "(" + Constants.SERVICE_PID + "=" + 
encode(configPid)
                         + ")";
                 Configuration[] configs = ca.listConfigurations(filter);
                 if (configs != null && configs.length > 0) {
@@ -142,15 +152,15 @@ abstract class ConfigUtil {
             Configuration configs[] = null;
             if ( configPid != null ) {
                 configs = ca.listConfigurations("(&("
-                        + ConfigurationAdmin.SERVICE_FACTORYPID + "=" + 
factoryPid
-                        + ")(" + Constants.SERVICE_PID + "=" + configPid
+                        + ConfigurationAdmin.SERVICE_FACTORYPID + "=" + 
encode(factoryPid)
+                        + ")(" + Constants.SERVICE_PID + "=" + 
encode(configPid)
                         + "))");
             }
             if (configs == null || configs.length == 0) {
                 // check for old style with alias pid
                 configs = ca.listConfigurations(
                         "(&(" + ConfigurationAdmin.SERVICE_FACTORYPID
-                        + "=" + factoryPid + ")(" + ALIAS_KEY + "=" + configPid
+                        + "=" + factoryPid + ")(" + ALIAS_KEY + "=" + 
encode(configPid)
                         + "))");
 
                 if (configs == null || configs.length == 0) {

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to