ruby-ldap/ruby-net-ldap — pull request #55 by jzinn (2013-01-27 09:20:06+00:00)
Title: Unescape escaped filter characters in #to_ber

I'm having an issue searching for LDAP entries by the `cn` attribute. When the values I'm searching for contain asterisks and backslashes, the search results are empty when they should not be.

For example I have an Active Directory group with `cn` value of `special*group`. A search with filter `Net::LDAP::Filter.begins(:cn, "special*g")` should find this group, but doesn't.

I compared Wireshark captures of this query with one using the `ldapsearch` command line tool. The bytes sent on the wire by `ldapsearch ... '(cn=special\2Ag*)'`, have a single `0x2a` byte (the hex value of the asterisk character) between `special` and `g`, whereas the net-ldap gem sends three bytes, one for `\`, one for `2`, and one for `A`.

This pull request will make the net-ldap gem behave like `ldapsearch`, and causes my search to return the expected results. However, I wonder if the net-ldap gem doesn't already work this way to prevent existing client code to break.

When the `unescape` method [was introduced](https://github.com/ruby-ldap/ruby-net-ldap/commit/089abcceb24cb9315e9edcdfbff397add7062f7b), the `#to_ber` method was updated to use `unescape` in some places. This pull request updates `#to_ber` to use `unescape` a few more times. I'm curious if there is a reason the previous commit decided not to use `unescape` where this pull request adds it.