From: jlaine Date: Fri, 25 Jun 2010 10:22:33 +0000 (+0000) Subject: make sure escape_ldap_filter handles unicode correctly X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=90db13b08fb27b2e7713be428583784c87426815;p=matthijs%2Fupstream%2Fdjango-ldapdb.git make sure escape_ldap_filter handles unicode correctly git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@930 e071eeec-0327-468d-9b6a-08194a12b294 --- diff --git a/ldapdb/__init__.py b/ldapdb/__init__.py index c6f0974..72f0889 100644 --- a/ldapdb/__init__.py +++ b/ldapdb/__init__.py @@ -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') \ diff --git a/ldapdb/tests.py b/ldapdb/tests.py index eea838e..2944f41 100644 --- a/ldapdb/tests.py +++ b/ldapdb/tests.py @@ -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')