Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlovetox <philipp@hoerist.com>2022-01-10 19:38:58 +0300
committerlovetox <philipp@hoerist.com>2022-01-10 19:38:58 +0300
commitdcce30a46c367286b2836f56a6492234d8489ab4 (patch)
tree68c1ff5c51086f5d1a739a27e7d2d41dee0ae859
parentdaf9c92cd6f2a81e491de53e88ad6a4281954f01 (diff)
JID: Add option to coerce to bare jid while parsing
-rw-r--r--nbxmpp/protocol.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/nbxmpp/protocol.py b/nbxmpp/protocol.py
index 35d8308..8814ed3 100644
--- a/nbxmpp/protocol.py
+++ b/nbxmpp/protocol.py
@@ -595,7 +595,7 @@ class JID:
@classmethod
@functools.lru_cache(maxsize=None)
- def from_string(cls, jid_string: str) -> JID:
+ def from_string(cls, jid_string: str, force_bare: bool = False) -> JID:
# https://tools.ietf.org/html/rfc7622#section-3.2
# Remove any portion from the first '/' character to the end of the
@@ -614,6 +614,11 @@ class JID:
else:
localpart, domainpart = None, rest
+ if force_bare:
+ if localpart is None:
+ raise LocalpartByteLimit
+ resourcepart = None
+
return cls(localpart=localpart,
domain=domainpart,
resource=resourcepart)