inejge / ldap3

A pure-Rust LDAP library using the Tokio stack
Apache License 2.0
220 stars 38 forks source link

Utility functions to escape strings #8

Closed lawliet89 closed 7 years ago

lawliet89 commented 7 years ago

Would it be possible to provide a utility module to provide functions for, say, search filters? I am sure there are other stuff that needs escaping, or some sort of special handling.

I wrote something, but I am not even sure if it's correct, because I am not familiar with LADP.

inejge commented 7 years ago

Note that escaping is needed only for value literals in the string representation of a filter, but yes, having a utility function for that is a good idea. I'll try add one for the next development release of the library (0.5.x).

What you wrote is correct AFAICS, as it completely captures the UTF1SUBSET production from RFC 4515.

lawliet89 commented 7 years ago

Right. I am guessing we don't have to worry about invalid UTF-8 for Rust because the strings are guaranteed to be valid UTF-8 and would have error-ed elsewhere.

Thanks.

inejge commented 7 years ago

Escaping function added in 5db4c395dfef97a5128d4df36a6b4a255230b561, but I won't close the issue until there's a published version on crates.io.

inejge commented 7 years ago

ldap_escape() is in 0.5.0, so this issue can be closed.