felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject svn commit: r615079 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java
Date Thu, 24 Jan 2008 23:28:04 GMT
Author: pauls
Date: Thu Jan 24 15:27:58 2008
New Revision: 615079

URL: http://svn.apache.org/viewvc?rev=615079&view=rev
Log:
Make FilterImpl.toString() add escape characters where needed (FELIX-471).

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java?rev=615079&r1=615078&r2=615079&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/util/ldap/Parser.java Thu
Jan 24 15:27:58 2008
@@ -1044,7 +1044,7 @@
 
         public void toStringInfix(StringBuffer b)
         {
-            b.append(val.toString());
+            appendEscaped(b, val.toString());
         }
     }
 
@@ -1195,12 +1195,12 @@
             b.append("=");
             for (int i = 0; i < pieces.length; i++)
             {
-                String piece = (String) pieces[i];
+                String piece = pieces[i];
                 if (i > 0)
                 {
                     b.append("*");
                 }
-                b.append(piece);
+                appendEscaped(b, piece);
             }
             b.append(")");
         }
@@ -1374,6 +1374,19 @@
         return false;
     }
 
+    private static void appendEscaped(StringBuffer buf, String value) 
+    {
+        for (int i = 0; i < value.length(); i++) 
+        {
+            char c = value.charAt(i);
+            if (c == '(' || c == ')' || c == '*' || c == '\\') 
+            {
+                buf.append('\\');
+            }
+            buf.append(c);
+        }
+    }
+    
     /**
      * This is an ugly utility method to convert an array of primitives
      * to an array of primitive wrapper objects. This method simplifies



Mime
View raw message