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 c6f0974476129a1e1d910d536ddc446f0027ef62..72f0889895c666b032c5433511f402c2c78b2cbf 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 eea838e7baf8f703b62aaa8b2bb3308d12127591..2944f417f40297c476a72532118c22a9304adb93 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')