mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-09 15:10:27 +00:00
fix of issue #1261
split record by "." idna.encode leads into full stop if the string starts with "_" or "-"
This commit is contained in:
parent
52169f698c
commit
97a79645b0
@ -258,18 +258,24 @@ def pretty_domain_name(value):
|
|||||||
raise Exception('Require the Punycode in string format')
|
raise Exception('Require the Punycode in string format')
|
||||||
|
|
||||||
def to_idna(value, action):
|
def to_idna(value, action):
|
||||||
splits = value.split()
|
splits = value.split('.')
|
||||||
result = []
|
result = []
|
||||||
if action == 'encode':
|
if action == 'encode':
|
||||||
for split in splits:
|
for split in splits:
|
||||||
try:
|
try:
|
||||||
# Try encoding to idna
|
# Try encoding to idna
|
||||||
result.append(idna.encode(split).decode())
|
if not split.startswith('_') and not split.startswith('-'):
|
||||||
|
result.append(idna.encode(split).decode())
|
||||||
|
else:
|
||||||
|
result.append(split)
|
||||||
except idna.IDNAError:
|
except idna.IDNAError:
|
||||||
result.append(split)
|
result.append(split)
|
||||||
elif action == 'decode':
|
elif action == 'decode':
|
||||||
for split in splits:
|
for split in splits:
|
||||||
result.append(idna.decode(split))
|
if not split.startswith('_') and not split.startswith('--'):
|
||||||
|
result.append(idna.decode(split))
|
||||||
|
else:
|
||||||
|
result.append(split)
|
||||||
else:
|
else:
|
||||||
raise Exception('No valid action received')
|
raise Exception('No valid action received')
|
||||||
return ' '.join(result)
|
return '.'.join(result)
|
||||||
|
Loading…
Reference in New Issue
Block a user