-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with non-latin characters #29
Comments
Since the library is in the ASCII mode, i offer little fix (or hack) to work with Cyrillic and possibly other charcters...Size of the cyrillic symbols in the "string" - 2 bytes, whereas the latin symbol - 1 byte. I did these steps:
diff for gopkg.in/ldap.v1/filter.go
|
Rather than using a hack to guess at non-ascii strings, I'd like to see correct handling of unicode. In my short googling I've found RFC 4518, and a go library for normalizing1 unicode to KC. I will try to work on this in the next few weeks, anyone else interested in working on this is welcome to also. |
+1 for proper escaping instead of regex tests/fixups |
This is very good news ;) Unicode - this is very good and versatile! I do not have work experience with unicode, but happy to learn it. For start, i will read the documentation and study the possibility of normalizing library. |
This is a slight modification of code using Unicode:This code works, I tested it with different search terms. While it is good to optimize and improve :)
|
Thanks for the investigation. If you have working code, could you put it in a branch and open a pull request? That would make it easier to review and check out for local testing. |
I created a pull request |
#31 for reference |
#32 for reference |
Hi! The problem appears when the search string contains Cyrillic (non-ascii) symbols.
Example for latin (ascii):
Search request: (|(displayName=Smith)(cn=Smith))
Debug from ldap library:
Debug by my printf in file gopkg.in/ldap.v1/filter.go, function compileFilter, line number 193:
Debug from LDAP Server:
55fbcb6d ==>backsql_search(): base="ou=sl it,ou=aup,ou=tsg,ou=quadra,o=enterprise", filter="(|(displayName=smith)(cn=smith))", scope=2, deref=0, attrsonly=0, attributes to load: custom list
55fbcb72 Constructed query: SELECT DISTINCT ldap_entries.id,ldapx_persons.id,text('inetOrgPerson') AS objectClass,ldap_entries.dn AS dn FROM ldap_entries,ldapx_persons WHERE ldapx_persons.id=ldap_entries.keyval AND ldap_entries.oc_map_id=? AND lower(ldap_entries.dn) LIKE lower('%'||?) AND ldapx_persons.lang=0 AND ((lower(text(ldapx_persons.fullname)) LIKE '%SMITH%') OR (lower(text(ldapx_persons.surname||' '||ldapx_persons.name)) LIKE '%SMITH%'))
All Good!
Example for Cyrilic (non-ascii):
I'll put pictures to avoid problems with Cyrillic and non-printable symbols.
Search request:
Debug from ldap library:
Debug by my printf in file gopkg.in/ldap.v1/filter.go, function compileFilter, line number 193:
Debug From LDAP Server:
...
The text was updated successfully, but these errors were encountered: