Parses RFC 4515 LDAP search filters into :eldap filters, with
placeholders filled in after parsing.
A placeholder is % and a letter; build/2 takes the value of each
letter, such as %{"u" => "alice@example.com"}. %% is a %, and a
letter without a value is left as it is.
Because placeholders are replaced in the parsed values, input cannot
change the filter's structure: *)(uid=* is just a strange name, never
an injection.
iex> {:ok, filter} = Sovite.LDAP.Filter.parse("(&(objectClass=person)(mail=%u))")
iex> Sovite.LDAP.Filter.build(filter, %{"u" => "a*b@example.com"})
{:and, [{:equalityMatch, {:AttributeValueAssertion, ~c"objectClass", ~c"person"}}, {:equalityMatch, {:AttributeValueAssertion, ~c"mail", ~c"a*b@example.com"}}]}
Summary
Functions
Fills in the placeholders from values and returns an :eldap filter.
Parses a filter string. Returns :error for invalid syntax.
Replaces the placeholders in string with values, escaping each
value with escape.
Types
Functions
Fills in the placeholders from values and returns an :eldap filter.
Parses a filter string. Returns :error for invalid syntax.
@spec substitute(String.t(), %{required(String.t()) => binary()}, (binary() -> binary())) :: binary()
Replaces the placeholders in string with values, escaping each
value with escape.