From df70e85e6f018f36d3998424a73cf05a24fb97e5 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 7 May 2019 12:11:20 +0100 Subject: [PATCH] accounts: Remove any control characters memcache does not like this and won't put things into its cache Signed-off-by: Michael Tremer --- src/backend/accounts.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/backend/accounts.py b/src/backend/accounts.py index 784ddabc..9b15a1c8 100644 --- a/src/backend/accounts.py +++ b/src/backend/accounts.py @@ -107,8 +107,8 @@ class Accounts(Object): def search(self, query): # Search for exact matches - accounts = self._search("(&(objectClass=person) \ - (|(uid=%s)(mail=%s)(sipAuthenticationUser=%s)(telephoneNumber=%s)(homePhone=%s)(mobile=%s)))" \ + accounts = self._search( + "(&(objectClass=person)(|(uid=%s)(mail=%s)(sipAuthenticationUser=%s)(telephoneNumber=%s)(homePhone=%s)(mobile=%s)))" \ % (query, query, query, query, query, query)) # Find accounts by name @@ -152,12 +152,19 @@ class Accounts(Object): return self.get_by_mail(s) def get_by_sip_id(self, sip_id): - return self._search_one("(|(&(objectClass=sipUser)(sipAuthenticationUser=%s)) \ - (&(objectClass=sipRoutingObject)(sipLocalAddress=%s)))" % (sip_id, sip_id)) + if not sip_id: + return + + return self._search_one( + "(|(&(objectClass=sipUser)(sipAuthenticationUser=%s))(&(objectClass=sipRoutingObject)(sipLocalAddress=%s)))" \ + % (sip_id, sip_id)) def get_by_phone_number(self, number): - return self._search_one("(&(objectClass=inetOrgPerson) \ - (|(sipAuthenticationUser=%s)(telephoneNumber=%s)(homePhone=%s)(mobile=%s)))" \ + if not number: + return + + return self._search_one( + "(&(objectClass=inetOrgPerson)(|(sipAuthenticationUser=%s)(telephoneNumber=%s)(homePhone=%s)(mobile=%s)))" \ % (number, number, number, number)) # Registration -- 2.47.3