Skip to content

Commit 99f2208

Browse files
author
tv
committed
Escape "=" in RDN values.
git-svn-id: svn+ssh://open.inoi.fi/open-ldaptor/trunk@194 373aa48d-36e5-0310-bb30-ae74d9883905
1 parent 8536f88 commit 99f2208

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

ldaptor/protocols/ldap/distinguishedname.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# See rfc2253
22

3-
escapedChars = r',+"\<>;'
3+
# Note that RFC 2253 sections 2.4 and 3 disagree whether "=" needs to
4+
# be quoted. Let's trust the syntax, slapd refuses to accept unescaped
5+
# "=" in RDN values.
6+
escapedChars = r',+"\<>;='
47
escapedChars_leading = r' #'
58
escapedChars_trailing = r' #'
69

ldaptor/test/test_distinguishedname.py

+28
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ class LDAPDistinguishedName_Escaping(TestCaseWithKnownValues):
8585

8686
(r'cn=bar\ ', [[('cn', r'bar ')]]),
8787

88+
(r'cn=test+owner=uid\=foo\,ou\=depar'
89+
+r'tment\,dc\=example\,dc\=com,dc=ex'
90+
+r'ample,dc=com', [[('cn', r'test'),
91+
('owner', r'uid=foo,ou=depart'
92+
+r'ment,dc=example,dc=com'),
93+
],
94+
[('dc', r'example')],
95+
[('dc', r'com')]]),
96+
8897
(r'cn=bar,dc=example,dc=com', [[('cn', 'bar')],
8998
[('dc', 'example')],
9099
[('dc', 'com')]]),
@@ -97,6 +106,25 @@ class LDAPDistinguishedName_Escaping(TestCaseWithKnownValues):
97106

98107
)
99108

109+
def testOpenLDAPEqualsEscape(self):
110+
"""Slapd wants = to be escaped in RDN attributeValues."""
111+
got = dn.DistinguishedName(listOfRDNs=[
112+
dn.RelativeDistinguishedName(
113+
attributeTypesAndValues=[
114+
dn.LDAPAttributeTypeAndValue(attributeType='cn', value=r'test'),
115+
dn.LDAPAttributeTypeAndValue(attributeType='owner', value=r'uid=foo,ou=depart'
116+
+r'ment,dc=example,dc=com'),
117+
]),
118+
119+
dn.RelativeDistinguishedName('dc=example'),
120+
dn.RelativeDistinguishedName('dc=com'),
121+
])
122+
got = str(got)
123+
self.assertEquals(got,
124+
r'cn=test+owner=uid\=foo\,ou\=depar'
125+
+r'tment\,dc\=example\,dc\=com,dc=ex'
126+
+r'ample,dc=com')
127+
100128
class LDAPDistinguishedName_RFC2253_Examples(TestCaseWithKnownValues):
101129
knownValues = (
102130

0 commit comments

Comments
 (0)