From: Brian B. <ex...@gm...> - 2004-11-11 04:42:43
|
> From: Bertrand Croq <ber...@fr...> > To: pyt...@li... > Subject: escape_dn_chars > > Hi, > I wasn't able to find a function to escape chars in DN strings, so I > wrote this one (based on escape_filter_chars): > > def escape_dn_chars(s): > s =3D s.replace('\\', r'\5C') > s =3D s.replace(',', r'\2C') > s =3D s.replace('=3D', r'\3D') > s =3D s.replace('+', r'\2B') > return s > Alternatively, wouldn't using urllib.quote do nearly the same thing? The only difference I notice is that quote uses a % as an escape character instead of \. That's easily changed... s = urllib.quote(s).replace('%', r'\') Or is there something about LDAP URIs that I'm missing? -- Brian Beck Adventurer of the First Order |