diff options
author | lovetox <philipp@hoerist.com> | 2020-08-26 10:35:07 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2020-08-26 10:35:07 +0300 |
commit | dac89332b570dedabfd4f0d13f10fa3a16c17f61 (patch) | |
tree | 255c9eea75344c094cee8f8167eaaf7e88809a33 /nbxmpp | |
parent | 5bd119438bfe0c9013b193d6b26b4299e3efa21d (diff) |
Don’t return domainpart encoded
Diffstat (limited to 'nbxmpp')
-rw-r--r-- | nbxmpp/protocol.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/nbxmpp/protocol.py b/nbxmpp/protocol.py index fcf07c0..adada1a 100644 --- a/nbxmpp/protocol.py +++ b/nbxmpp/protocol.py @@ -721,19 +721,19 @@ def validate_domainpart(domainpart): if GLib.hostname_is_ip_address(ip_address): return ip_address + length = len(domainpart.encode()) + if length == 0 or length > 1023: + raise DomainpartByteLimit + if domainpart.endswith('.'): # RFC7622, 3.2 domainpart = domainpart[:-1] try: - domainpart = idna.encode(domainpart, uts46=True) + idna.encode(domainpart, uts46=True) except Exception: raise DomainpartNotAllowedChar - length = len(domainpart) - if length == 0 or length > 1023: - raise DomainpartByteLimit - - return domainpart.decode() + return domainpart class JID: |