Skip to content

Commit c225344

Browse files
authored
Merge branch 'master' into 2.7-dev
2 parents d9a6b81 + d2dea88 commit c225344

File tree

11 files changed

+436
-1292
lines changed

11 files changed

+436
-1292
lines changed

HISTORY.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@
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-
146
2.6 (2017-08-08)
157
++++++++++++++++
168

idna/core.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -352,17 +352,15 @@ 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-
if not labels or labels == ['']:
355+
while labels and not labels[0]:
356+
del labels[0]
357+
if not labels:
356358
raise IDNAError('Empty domain')
357359
if labels[-1] == '':
358360
del labels[-1]
359361
trailing_dot = True
360362
for label in labels:
361-
s = alabel(label)
362-
if s:
363-
result.append(s)
364-
else:
365-
raise IDNAError('Empty label')
363+
result.append(alabel(label))
366364
if trailing_dot:
367365
result.append(b'')
368366
s = b'.'.join(result)
@@ -383,17 +381,15 @@ def decode(s, strict=False, uts46=False, std3_rules=False):
383381
labels = _unicode_dots_re.split(s)
384382
else:
385383
labels = s.split(u'.')
386-
if not labels or labels == ['']:
384+
while labels and not labels[0]:
385+
del labels[0]
386+
if not 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-
s = ulabel(label)
393-
if s:
394-
result.append(s)
395-
else:
396-
raise IDNAError('Empty label')
392+
result.append(ulabel(label))
397393
if trailing_dot:
398394
result.append(u'')
399395
return u'.'.join(result)

0 commit comments

Comments
 (0)