Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
dcce30a4 by lovetox at 2022-01-10T17:38:58+01:00
JID: Add option to coerce to bare jid while parsing
- - - - -
21e8df5c by lovetox at 2022-01-10T17:49:11+01:00
MUC: Force muc user real JIDs to bare
Its unspecified if servers need to send a full JID or bare JID here.
Further its also unspecified if they need to send all full JIDs of
all connected resources.
So we implement on what we can actually depend, there needs to be
at least a bare JID.
- - - - -
2 changed files:
- nbxmpp/modules/muc/util.py
- nbxmpp/protocol.py
Changes:
=====================================
nbxmpp/modules/muc/util.py
=====================================
@@ -177,7 +177,7 @@ def parse_muc_user(muc_user, is_presence=True):
jid = item_dict.get('jid')
if jid is not None:
try:
- jid = JID.from_string(jid)
+ jid = JID.from_string(jid, force_bare=True)
except InvalidJid as error:
raise StanzaMalformed('invalid jid %s, %s' % (jid, error))
=====================================
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)
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/-/compare/daf9c92cd6f2a81e491de53e88ad6a4281954f01...21e8df5cd14841360ffd329d7f8aa989bd56a135
--
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/-/compare/daf9c92cd6f2a81e491de53e88ad6a4281954f01...21e8df5cd14841360ffd329d7f8aa989bd56a135
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits