Philipp Hörist pushed to branch master at gajim / gajim
Commits:
99f52e7e by Philipp Hörist at 2019-12-09T20:20:12Z
Add more options for validating JIDs
- - - - -
1 changed file:
- gajim/common/helpers.py
Changes:
=====================================
gajim/common/helpers.py
=====================================
@@ -1627,12 +1627,23 @@ def get_default_muc_config():
}
-def validate_jid(jid):
+def validate_jid(jid, type_=None):
try:
- return JID(str(jid))
+ jid = JID(str(jid))
except InvalidJid as error:
raise ValueError(error)
+ if type_ is None:
+ return jid
+ if type_ == 'bare' and jid.isBare:
+ return jid
+ if type_ == 'full' and jid.isFull:
+ return jid
+ if type_ == 'domain' and jid.isDomain:
+ return jid
+
+ raise ValueError('Not a %s JID' % type_)
+
def to_user_string(error):
text = error.get_text(get_rfc5646_lang())
View it on GitLab:
https://dev.gajim.org/gajim/gajim/commit/99f52e7e9ef84863fd8d52830d2594823d0bf648
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/commit/99f52e7e9ef84863fd8d52830d2594823d0bf648
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