changeset 3205:0e0bdcd9c101

6979376: to have ldap filters tolerate underscore character in object identifier Reviewed-by: weijun
author xuelei
date Thu, 02 Dec 2010 23:44:01 -0800
parents 8b2025d6f257
children e3dbb8cd8820 f32b03dc4e76
files src/share/classes/com/sun/jndi/ldap/Filter.java test/com/sun/jndi/ldap/InvalidLdapFilters.java
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/jndi/ldap/Filter.java	Wed Dec 01 15:58:49 2010 -0800
+++ b/src/share/classes/com/sun/jndi/ldap/Filter.java	Thu Dec 02 23:44:01 2010 -0800
@@ -427,7 +427,10 @@
                     }
                 } else {
                     // descriptor
-                    if (filter[i] != '-' &&
+                    // The underscore ("_") character is not allowed by
+                    // the LDAP specification. We allow it here to
+                    // tolerate the incorrect use in practice.
+                    if (filter[i] != '-' && filter[i] != '_' &&
                         !(filter[i] >= '0' && filter[i] <= '9') &&
                         !(filter[i] >= 'A' && filter[i] <= 'Z') &&
                         !(filter[i] >= 'a' && filter[i] <= 'z')) {
@@ -467,7 +470,10 @@
                     break;
                 }
 
-                if (filter[i] != '-' &&
+                // The underscore ("_") character is not allowed by
+                // the LDAP specification. We allow it here to
+                // tolerate the incorrect use in practice.
+                if (filter[i] != '-' && filter[i] != '_' &&
                         !(filter[i] >= '0' && filter[i] <= '9') &&
                         !(filter[i] >= 'A' && filter[i] <= 'Z') &&
                         !(filter[i] >= 'a' && filter[i] <= 'z')) {
@@ -515,7 +521,10 @@
                             }
                         } else {
                             // descriptor
-                            if (filter[j] != '-' &&
+                            // The underscore ("_") character is not allowed by
+                            // the LDAP specification. We allow it here to
+                            // tolerate the incorrect use in practice.
+                            if (filter[j] != '-' && filter[j] != '_' &&
                                 !(filter[j] >= '0' && filter[j] <= '9') &&
                                 !(filter[j] >= 'A' && filter[j] <= 'Z') &&
                                 !(filter[j] >= 'a' && filter[j] <= 'z')) {
--- a/test/com/sun/jndi/ldap/InvalidLdapFilters.java	Wed Dec 01 15:58:49 2010 -0800
+++ b/test/com/sun/jndi/ldap/InvalidLdapFilters.java	Thu Dec 02 23:44:01 2010 -0800
@@ -48,6 +48,8 @@
  * @run main/othervm InvalidLdapFilters valid (sn;lang-en:dn:2.4.6.8.10:=Barney)
  * @run main/othervm InvalidLdapFilters valid
          (&(objectClass=Person)(|(sn=Jensen)(cn=Bab*)))
+ * @run main/othervm InvalidLdapFilters valid
+         (orcluserapplnprovstatus;EMAIL_email=PROVISIONING_FAILURE)
  * @run main/othervm InvalidLdapFilters invalid "(&(cn=Robert Dean)))"
  * @run main/othervm InvalidLdapFilters invalid (&|(cn=Bob))
  * @run main/othervm InvalidLdapFilters invalid (&&(cn=Bob))