make sure escape_ldap_filter handles unicode correctly
authorjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Fri, 25 Jun 2010 10:22:33 +0000 (10:22 +0000)
committerjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Fri, 25 Jun 2010 10:22:33 +0000 (10:22 +0000)
git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@930 e071eeec-0327-468d-9b6a-08194a12b294

ldapdb/__init__.py
ldapdb/tests.py

index c6f0974..72f0889 100644 (file)
@@ -38,7 +38,7 @@ from django.conf import settings
 from django.db.backends import BaseDatabaseFeatures, BaseDatabaseOperations
 
 def escape_ldap_filter(value):
-    value = str(value)
+    value = unicode(value)
     return value.replace('\\', '\\5c') \
                 .replace('*', '\\2a') \
                 .replace('(', '\\28') \
index eea838e..2944f41 100644 (file)
@@ -41,6 +41,7 @@ from ldapdb.models.query import WhereNode
 
 class WhereTestCase(TestCase):
     def test_escape(self):
+        self.assertEquals(escape_ldap_filter(u'fôöbàr'), u'fôöbàr')
         self.assertEquals(escape_ldap_filter('foo*bar'), 'foo\\2abar')
         self.assertEquals(escape_ldap_filter('foo(bar'), 'foo\\28bar')
         self.assertEquals(escape_ldap_filter('foo)bar'), 'foo\\29bar')