Skip to content

Commit 1b377da

Browse files
committed
Unwind bad merge to 2.7-dev HEAD
1 parent c225344 commit 1b377da

File tree

11 files changed

+1292
-436
lines changed

11 files changed

+1292
-436
lines changed

HISTORY.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
History
44
-------
55

6+
2.7 (2018-03-XX)
7+
++++++++++++++++
8+
9+
- Update to Unicode 10.0.0.
10+
- No longer accepts dot-prefixed domains (e.g. ".example') as valid.
11+
This is to be more conformant with the UTS 46 spec. Users should
12+
strip dot prefixes from domains before processing.
13+
614
2.6 (2017-08-08)
715
++++++++++++++++
816

idna/core.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,15 +352,17 @@ def encode(s, strict=False, uts46=False, std3_rules=False, transitional=False):
352352
labels = s.split('.')
353353
else:
354354
labels = _unicode_dots_re.split(s)
355-
while labels and not labels[0]:
356-
del labels[0]
357-
if not labels:
355+
if not labels or labels == ['']:
358356
raise IDNAError('Empty domain')
359357
if labels[-1] == '':
360358
del labels[-1]
361359
trailing_dot = True
362360
for label in labels:
363-
result.append(alabel(label))
361+
s = alabel(label)
362+
if s:
363+
result.append(s)
364+
else:
365+
raise IDNAError('Empty label')
364366
if trailing_dot:
365367
result.append(b'')
366368
s = b'.'.join(result)
@@ -381,15 +383,17 @@ def decode(s, strict=False, uts46=False, std3_rules=False):
381383
labels = _unicode_dots_re.split(s)
382384
else:
383385
labels = s.split(u'.')
384-
while labels and not labels[0]:
385-
del labels[0]
386-
if not labels:
386+
if not labels or labels == ['']:
387387
raise IDNAError('Empty domain')
388388
if not labels[-1]:
389389
del labels[-1]
390390
trailing_dot = True
391391
for label in labels:
392-
result.append(ulabel(label))
392+
s = ulabel(label)
393+
if s:
394+
result.append(s)
395+
else:
396+
raise IDNAError('Empty label')
393397
if trailing_dot:
394398
result.append(u'')
395399
return u'.'.join(result)

0 commit comments

Comments
 (0)