From ed514e6f73298f5b24a6d6940584e4c8316fc759 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 18 Nov 2021 15:33:37 +0100 Subject: jid: Improve error reporting on IDNA validation failure At least knowing the failing domain should help a lot while debugging. --- slixmpp/jid.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/slixmpp/jid.py b/slixmpp/jid.py index adde95a4..d02f98a3 100644 --- a/slixmpp/jid.py +++ b/slixmpp/jid.py @@ -133,15 +133,15 @@ def _validate_domain(domain: str): try: domain = idna(domain) except StringprepError: - raise InvalidJID('idna validation failed') + raise InvalidJID(f'idna validation failed: {domain}') if ':' in domain: - raise InvalidJID('Domain containing a port') + raise InvalidJID(f'Domain containing a port: {domain}') for label in domain.split('.'): if not label: - raise InvalidJID('Domain containing too many dots') + raise InvalidJID(f'Domain containing too many dots: {domain}') if '-' in (label[0], label[-1]): - raise InvalidJID('Domain started or ended with -') + raise InvalidJID(f'Domain starting or ending with -: {domain}') if not domain: raise InvalidJID('Domain must not be 0 bytes') -- cgit v1.2.3