From cd184619a6434c011bbb5bea2d258e0b966a7c65 Mon Sep 17 00:00:00 2001 From: Florian Best Date: Sun, 17 Mar 2019 13:56:24 +0100 Subject: [PATCH 1/2] escape_dn_chars(): Adjust test cases to include all escaped characters --- Tests/t_ldap_dn.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Tests/t_ldap_dn.py b/Tests/t_ldap_dn.py index 4b4dd319..fd36f866 100644 --- a/Tests/t_ldap_dn.py +++ b/Tests/t_ldap_dn.py @@ -50,6 +50,11 @@ def test_escape_dn_chars(self): self.assertEqual(ldap.dn.escape_dn_chars('#foobar'), '\\#foobar') self.assertEqual(ldap.dn.escape_dn_chars('foo bar'), 'foo bar') self.assertEqual(ldap.dn.escape_dn_chars(' foobar'), '\\ foobar') + self.assertEqual(ldap.dn.escape_dn_chars(' '), '\\ ') + self.assertEqual(ldap.dn.escape_dn_chars(' '), '\\ \\ ') + self.assertEqual(ldap.dn.escape_dn_chars('foobar '), 'foobar\\ ') + self.assertEqual(ldap.dn.escape_dn_chars('f+o>o,bo\\,b\\ Date: Sun, 17 Mar 2019 13:56:51 +0100 Subject: [PATCH 2/2] Fix escape_dn_chars(' ') --- Lib/ldap/dn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/ldap/dn.py b/Lib/ldap/dn.py index 00c7b064..cabfed84 100644 --- a/Lib/ldap/dn.py +++ b/Lib/ldap/dn.py @@ -29,10 +29,10 @@ def escape_dn_chars(s): s = s.replace(';' ,'\\;') s = s.replace('=' ,'\\=') s = s.replace('\000' ,'\\\000') - if s[0]=='#' or s[0]==' ': - s = ''.join(('\\',s)) if s[-1]==' ': s = ''.join((s[:-1],'\\ ')) + if s[0]=='#' or s[0]==' ': + s = ''.join(('\\',s)) return s pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy