From 3f0eb1417ca0162861a05e3ced6a532b3cfba2ab Mon Sep 17 00:00:00 2001 From: Martin Kosek Date: Wed, 23 Nov 2011 16:03:51 +0100 Subject: Improve zonemgr validator and normalizer The validator has been improved to support better both SOA format (e-mail address in a domain name format, without '@') and standard e-mail format. Allow '\.' character in a SOA format encoding the standard '.' in the local-part of an e-mail. Normalization code has been moved to one common function. https://fedorahosted.org/freeipa/ticket/2053 --- ipalib/plugins/dns.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'ipalib/plugins') diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py index bfc8090c..e3522c90 100644 --- a/ipalib/plugins/dns.py +++ b/ipalib/plugins/dns.py @@ -27,7 +27,7 @@ from ipalib import Command from ipalib import Flag, Bool, Int, List, Str, StrEnum from ipalib.plugins.baseldap import * from ipalib import _, ngettext -from ipalib.util import validate_zonemgr, validate_hostname +from ipalib.util import validate_zonemgr, normalize_zonemgr, validate_hostname from ipapython import dnsclient from ipapython.ipautil import valid_ip from ldap import explode_dn @@ -152,13 +152,6 @@ def _rname_validator(ugettext, zonemgr): return unicode(e) return None -# normalizer for admin email -def _rname_normalizer(value): - value = value.replace('@', '.') - if not value.endswith('.'): - value += '.' - return value - def _create_zone_serial(**kwargs): """Generate serial number for zones.""" return int('%s01' % time.strftime('%Y%d%m')) @@ -678,7 +671,7 @@ class dnszone(LDAPObject): label=_('Administrator e-mail address'), doc=_('Administrator e-mail address'), default_from=lambda idnsname: 'root.%s' % idnsname, - normalizer=_rname_normalizer, + normalizer=normalize_zonemgr, ), Int('idnssoaserial?', cli_name='serial', -- cgit