incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1394467 - in /sling/trunk: installer/factories/configuration/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtil.java launchpad/builder/src/main/bundles/list.xml
Date Fri, 05 Oct 2012 12:03:02 GMT
Author: cziegeler
Date: Fri Oct  5 12:03:02 2012
New Revision: 1394467

URL: http://svn.apache.org/viewvc?rev=1394467&view=rev
Log:
FELIX-2578 :  Filter value should be escaped 

Modified:
    sling/trunk/installer/factories/configuration/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtil.java
    sling/trunk/launchpad/builder/src/main/bundles/list.xml

Modified: sling/trunk/installer/factories/configuration/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtil.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/factories/configuration/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtil.java?rev=1394467&r1=1394466&r2=1394467&view=diff
==============================================================================
--- sling/trunk/installer/factories/configuration/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtil.java
(original)
+++ sling/trunk/installer/factories/configuration/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigUtil.java
Fri Oct  5 12:03:02 2012
@@ -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) {

Modified: sling/trunk/launchpad/builder/src/main/bundles/list.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/builder/src/main/bundles/list.xml?rev=1394467&r1=1394466&r2=1394467&view=diff
==============================================================================
--- sling/trunk/launchpad/builder/src/main/bundles/list.xml (original)
+++ sling/trunk/launchpad/builder/src/main/bundles/list.xml Fri Oct  5 12:03:02 2012
@@ -228,7 +228,7 @@
         <bundle>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.installer.factory.configuration</artifactId>
-            <version>1.0.8</version>
+            <version>1.0.9-SNAPSHOT</version>
         </bundle>
         <bundle>
             <groupId>org.apache.sling</groupId>



Mime
View raw message