Non IDNA zonename should be normalized to lowercase

Before IDNA support zone was normalized.

Reviewed-By: Petr Spacek <pspacek@redhat.com>
This commit is contained in:
Martin Basti 2014-07-03 18:14:40 +02:00 committed by Martin Kosek
parent 6f2451ce9e
commit 29951ada9f

View File

@ -1708,6 +1708,15 @@ def _records_idn_postprocess(record, **options):
rrs.append(dnsvalue)
record[attr] = rrs
def _normalize_zone(zone):
if isinstance(zone, unicode):
# normalize only non-IDNA zones
try:
return unicode(zone.encode('ascii')).lower()
except UnicodeError:
pass
return zone
class DNSZoneBase(LDAPObject):
"""
@ -1727,6 +1736,7 @@ class DNSZoneBase(LDAPObject):
label=_('Zone name'),
doc=_('Zone name (FQDN)'),
default_from=lambda name_from_ip: _reverse_zone_name(name_from_ip),
normalizer=_normalize_zone,
primary_key=True,
),
Str('name_from_ip?', _validate_ipnet,