6979376: to have ldap filters tolerate underscore character in object identifier
Reviewed-by: weijun
--- a/jdk/src/share/classes/com/sun/jndi/ldap/Filter.java Wed Dec 01 15:58:49 2010 -0800
+++ b/jdk/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/jdk/test/com/sun/jndi/ldap/InvalidLdapFilters.java Wed Dec 01 15:58:49 2010 -0800
+++ b/jdk/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))