8a3e232332
- Cleanup spec - Patch to fix unicode escapes - Drop el6 from master (el6 requires patch for 1.16.0)
85 lines
2.6 KiB
Diff
85 lines
2.6 KiB
Diff
diff -ru dnspython-1.16.0-orig/dns/name.py dnspython-1.16.0/dns/name.py
|
|
--- dnspython-1.16.0-orig/dns/name.py 2018-12-05 08:35:40.000000000 -0500
|
|
+++ dnspython-1.16.0/dns/name.py 2019-07-28 08:48:37.893331388 -0400
|
|
@@ -110,15 +110,23 @@
|
|
def __init__(self):
|
|
pass
|
|
|
|
+ def is_idna(self, label):
|
|
+ return label.lower().startswith(b'xn--')
|
|
+
|
|
+ def is_all_ascii(self, label):
|
|
+ for c in label:
|
|
+ if ord(c) > 0x7f:
|
|
+ return False
|
|
+ return True
|
|
+
|
|
def encode(self, label):
|
|
raise NotImplementedError
|
|
|
|
def decode(self, label):
|
|
- # We do not apply any IDNA policy on decode; we just
|
|
- downcased = label.lower()
|
|
- if downcased.startswith(b'xn--'):
|
|
+ # We do not apply any IDNA policy on decode.
|
|
+ if self.is_idna(label):
|
|
try:
|
|
- label = downcased[4:].decode('punycode')
|
|
+ label = label[4:].decode('punycode')
|
|
except Exception as e:
|
|
raise IDNAException(idna_exception=e)
|
|
else:
|
|
@@ -195,12 +203,6 @@
|
|
self.allow_pure_ascii = allow_pure_ascii
|
|
self.strict_decode = strict_decode
|
|
|
|
- def is_all_ascii(self, label):
|
|
- for c in label:
|
|
- if ord(c) > 0x7f:
|
|
- return False
|
|
- return True
|
|
-
|
|
def encode(self, label):
|
|
if label == '':
|
|
return b''
|
|
@@ -230,6 +232,7 @@
|
|
raise IDNAException(idna_exception=e)
|
|
|
|
_escaped = bytearray(b'"().;\\@$')
|
|
+_escaped_text = u'"().;\\@$'
|
|
|
|
IDNA_2003_Practical = IDNA2003Codec(False)
|
|
IDNA_2003_Strict = IDNA2003Codec(True)
|
|
@@ -265,11 +268,12 @@
|
|
for c in label:
|
|
if c > u'\x20' and c < u'\x7f':
|
|
text += c
|
|
+ if c in _escaped_text:
|
|
+ text += '\\' + c
|
|
+ elif c <= '\x20':
|
|
+ text += '\\%03d' % ord(c)
|
|
else:
|
|
- if c >= u'\x7f':
|
|
- text += c
|
|
- else:
|
|
- text += u'\\%03d' % ord(c)
|
|
+ tect += c
|
|
return text
|
|
|
|
def _validate_labels(labels):
|
|
diff -ru dnspython-1.16.0-orig/tests/test_name.py dnspython-1.16.0/tests/test_name.py
|
|
--- dnspython-1.16.0-orig/tests/test_name.py 2018-12-01 10:48:40.000000000 -0500
|
|
+++ dnspython-1.16.0/tests/test_name.py 2019-07-28 08:52:46.831657776 -0400
|
|
@@ -255,6 +255,11 @@
|
|
t = dns.name.root.to_unicode()
|
|
self.assertEqual(t, '.')
|
|
|
|
+ def testToText12(self):
|
|
+ n = dns.name.from_text(r'a\.b.c')
|
|
+ t = n.to_unicode()
|
|
+ self.assertEqual(t, r'a\.b.c.')
|
|
+
|
|
def testSlice1(self):
|
|
n = dns.name.from_text(r'a.b.c.', origin=None)
|
|
s = n[:]
|