mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Raise right exception if domain name is not valid
Because of dnspython implementation, in some cases UnicodeError is raised instead of DNS SyntaxError Ticket: https://fedorahosted.org/freeipa/ticket/4734 Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
committed by
Jan Cholasta
parent
bff97e8b2e
commit
c80a59eff4
@@ -26,15 +26,16 @@ class DNSName(dns.name.Name):
|
||||
labels = None # make pylint happy
|
||||
|
||||
def __init__(self, labels, origin=None):
|
||||
if isinstance(labels, str):
|
||||
#pylint: disable=E1101
|
||||
labels = dns.name.from_text(labels, origin).labels
|
||||
elif isinstance(labels, unicode):
|
||||
#pylint: disable=E1101
|
||||
labels = dns.name.from_unicode(labels, origin).labels
|
||||
elif isinstance(labels, dns.name.Name):
|
||||
labels = labels.labels
|
||||
try:
|
||||
if isinstance(labels, str):
|
||||
#pylint: disable=E1101
|
||||
labels = dns.name.from_text(labels, origin).labels
|
||||
elif isinstance(labels, unicode):
|
||||
#pylint: disable=E1101
|
||||
labels = dns.name.from_unicode(labels, origin).labels
|
||||
elif isinstance(labels, dns.name.Name):
|
||||
labels = labels.labels
|
||||
|
||||
super(DNSName, self).__init__(labels)
|
||||
except UnicodeError, e:
|
||||
# dnspython bug, an invalid domain name returns the UnicodeError
|
||||
|
||||
Reference in New Issue
Block a user