[openpgp] Be more resistant against invalid keys

This commit is contained in:
lovetox
2022-04-18 14:04:43 +02:00
parent be9afe8719
commit 572301fe89
3 changed files with 98 additions and 58 deletions

13
openpgp/backend/util.py Normal file
View File

@@ -0,0 +1,13 @@
from __future__ import annotations
def parse_uid(uid: str, compat=False) -> str:
if uid.startswith('xmpp:'):
return uid[5:]
# Compat with uids of form "Name <xmpp:my@jid.com>"
if compat and '<xmpp:' in uid and uid.endswith('>'):
return uid[:-1].split('<xmpp:', maxsplit=1)[1]
raise ValueError('Uknown UID format: %s' % uid)