From e8ba274776d51f3f4301ce8fce49f55865880a39 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 10 Aug 2019 13:23:35 +0300 Subject: [PATCH] Use unicodedata for cleaning up whitespace names --- mautrix_telegram/puppet.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mautrix_telegram/puppet.py b/mautrix_telegram/puppet.py index d7be58de..3fd9f571 100644 --- a/mautrix_telegram/puppet.py +++ b/mautrix_telegram/puppet.py @@ -15,6 +15,7 @@ # along with this program. If not, see . from typing import Awaitable, Any, Dict, Iterable, Optional, Union, TYPE_CHECKING from difflib import SequenceMatcher +import unicodedata import asyncio import logging @@ -194,7 +195,7 @@ class Puppet(CustomPuppetMixin): whitespace = ("\t\n\r\v\f \u00a0\u034f\u180e\u2063\u202f\u205f\u2800\u3000\u3164\ufeff" "\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b" "\u200c\u200d\u200e\u200f") - name = name.strip(whitespace) + name = str(filter(lambda c: unicodedata.category(c) != 'Cf', name.strip(whitespace))) return name @classmethod