Remove non-BMP characters
This commit is contained in:
parent
b896c215ec
commit
8a0449a632
@ -6,6 +6,9 @@ from slixmpp.types import PresenceArgs
|
||||
import slixmpp.stanza
|
||||
import slixmpp.plugins.xep_0084.stanza
|
||||
import base64, time
|
||||
NON_BMP_RE = re.compile(u"[^\U00000000-\U0000d7ff\U0000e000-\U0000ffff]", flags=re.UNICODE)
|
||||
def non_bmp(s):
|
||||
return NON_BMP_RE.sub(u'', s)
|
||||
|
||||
class GatewayXMPP(ComponentXMPP):
|
||||
def __init__(self, plexus, settings, gateway_name, gateway_data):
|
||||
@ -60,6 +63,8 @@ class GatewayXMPP(ComponentXMPP):
|
||||
# Ignore ours
|
||||
return
|
||||
|
||||
nick_name = non_bmp(nick_name)
|
||||
|
||||
puppet_data = {
|
||||
"identification": identification,
|
||||
"jid": f"{hashlib.sha256(str(identification).encode()).hexdigest()[:24]}@{self.pfrom}/mirror",
|
||||
@ -113,6 +118,7 @@ class GatewayXMPP(ComponentXMPP):
|
||||
puppet_data["queue"].append(queue_callback)
|
||||
|
||||
# If the user changed their nickname, try to update it on the puppet
|
||||
nick_name = non_bmp(nick_name)
|
||||
if nick_name != puppet_data["nicknames"][muc_jid]["nick"]:
|
||||
assert puppet_data["nicknames"][muc_jid]["state"] == "joined"
|
||||
puppet_data["nicknames"][muc_jid]["state"] = "joining"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user