Philipp Hörist pushed to branch master at gajim / python-nbxmpp

Commits:

1 changed file:

Changes:

  • nbxmpp/protocol.py
    ... ... @@ -20,10 +20,11 @@ sub- stanzas) handling routines
    20 20
     
    
    21 21
     import time
    
    22 22
     import hashlib
    
    23
    -import socket
    
    24 23
     import functools
    
    25 24
     from base64 import b64encode
    
    26 25
     
    
    26
    +from gi.repository import GLib
    
    27
    +
    
    27 28
     import idna
    
    28 29
     from precis_i18n import get_profile
    
    29 30
     from nbxmpp.simplexml import Node
    
    ... ... @@ -716,20 +717,8 @@ def validate_domainpart(domainpart):
    716 717
         if not domainpart:
    
    717 718
             raise DomainpartByteLimit
    
    718 719
     
    
    719
    -    # Check if this is a IPV4 address
    
    720
    -    try:
    
    721
    -        socket.inet_aton(domainpart)
    
    720
    +    if GLib.hostname_is_ip_address(domainpart):
    
    722 721
             return domainpart
    
    723
    -    except Exception:
    
    724
    -        pass
    
    725
    -
    
    726
    -    # Check if this is a IPV6 address
    
    727
    -    if domainpart.startswith('[') and domainpart.endswith(']'):
    
    728
    -        try:
    
    729
    -            socket.inet_pton(socket.AF_INET6, domainpart.strip('[]'))
    
    730
    -            return domainpart
    
    731
    -        except Exception:
    
    732
    -            pass
    
    733 722
     
    
    734 723
         if domainpart.endswith('.'):  # RFC7622, 3.2
    
    735 724
             domainpart = domainpart[:-1]