|
|
e3ffab |
From e2f285e7c63a8ff9f2c049ee3a058b6e281352a8 Mon Sep 17 00:00:00 2001
|
|
|
e3ffab |
From: Martin Basti <mbasti@redhat.com>
|
|
|
e3ffab |
Date: Wed, 19 Nov 2014 14:51:20 +0100
|
|
|
e3ffab |
Subject: [PATCH] Raise right exception if domain name is not valid
|
|
|
e3ffab |
|
|
|
e3ffab |
Because of dnspython implementation, in some cases UnicodeError is
|
|
|
e3ffab |
raised instead of DNS SyntaxError
|
|
|
e3ffab |
|
|
|
e3ffab |
Ticket: https://fedorahosted.org/freeipa/ticket/4734
|
|
|
e3ffab |
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
|
|
|
e3ffab |
---
|
|
|
e3ffab |
ipapython/dnsutil.py | 17 +++++++++--------
|
|
|
e3ffab |
1 file changed, 9 insertions(+), 8 deletions(-)
|
|
|
e3ffab |
|
|
|
e3ffab |
diff --git a/ipapython/dnsutil.py b/ipapython/dnsutil.py
|
|
|
e3ffab |
index d7841fe2548dd100d51e60ea11bc6e468f3475cf..f08cddad959658a11623a31cb591655f1a5fdabf 100644
|
|
|
e3ffab |
--- a/ipapython/dnsutil.py
|
|
|
e3ffab |
+++ b/ipapython/dnsutil.py
|
|
|
e3ffab |
@@ -26,15 +26,16 @@ class DNSName(dns.name.Name):
|
|
|
e3ffab |
labels = None # make pylint happy
|
|
|
e3ffab |
|
|
|
e3ffab |
def __init__(self, labels, origin=None):
|
|
|
e3ffab |
- if isinstance(labels, str):
|
|
|
e3ffab |
- #pylint: disable=E1101
|
|
|
e3ffab |
- labels = dns.name.from_text(labels, origin).labels
|
|
|
e3ffab |
- elif isinstance(labels, unicode):
|
|
|
e3ffab |
- #pylint: disable=E1101
|
|
|
e3ffab |
- labels = dns.name.from_unicode(labels, origin).labels
|
|
|
e3ffab |
- elif isinstance(labels, dns.name.Name):
|
|
|
e3ffab |
- labels = labels.labels
|
|
|
e3ffab |
try:
|
|
|
e3ffab |
+ if isinstance(labels, str):
|
|
|
e3ffab |
+ #pylint: disable=E1101
|
|
|
e3ffab |
+ labels = dns.name.from_text(labels, origin).labels
|
|
|
e3ffab |
+ elif isinstance(labels, unicode):
|
|
|
e3ffab |
+ #pylint: disable=E1101
|
|
|
e3ffab |
+ labels = dns.name.from_unicode(labels, origin).labels
|
|
|
e3ffab |
+ elif isinstance(labels, dns.name.Name):
|
|
|
e3ffab |
+ labels = labels.labels
|
|
|
e3ffab |
+
|
|
|
e3ffab |
super(DNSName, self).__init__(labels)
|
|
|
e3ffab |
except UnicodeError, e:
|
|
|
e3ffab |
# dnspython bug, an invalid domain name returns the UnicodeError
|
|
|
e3ffab |
--
|
|
|
e3ffab |
2.1.0
|
|
|
e3ffab |
|