From 90db13b08fb27b2e7713be428583784c87426815 Mon Sep 17 00:00:00 2001 From: jlaine Date: Fri, 25 Jun 2010 10:22:33 +0000 Subject: [PATCH] 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 --- ldapdb/__init__.py | 2 +- ldapdb/tests.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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') -- 2.30.2