From 2af96d1c0bd3b39dd9ab4ab2b35b924eed5c5d69 Mon Sep 17 00:00:00 2001 From: Petr Spacek Date: Mon, 17 Feb 2014 14:37:28 +0100 Subject: Fix regular expression for LOC records in DNS. - Fractional parts of integers are not mandatory. - Expressions containing only size or only size + horizontal precision are allowed. - N/S/W/E handling was fixed. See RFC 1876 section 3 for details. Reviewed-By: Petr Viktorin --- ipalib/plugins/dns.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py index caaeaf16..e7301a9f 100644 --- a/ipalib/plugins/dns.py +++ b/ipalib/plugins/dns.py @@ -1136,14 +1136,19 @@ class LOCRecord(DNSRecord): See RFC 1876 for details""") def _get_part_values(self, value): - regex = re.compile(\ - r'(?P\d{1,2}\s+)(?P\d{1,2}\s+)?(?P\d{1,2}\.?\d{1,3}?\s+)?'\ - r'(?P[N|S])\s+'\ - r'(?P\d{1,3}\s+)(?P\d{1,2}\s+)?(?P\d{1,2}\.?\d{1,3}?\s+)?'\ - r'(?P[W|E])\s+'\ - r'(?P-?\d{1,8}\.?\d{1,2}?)m?\s*'\ - r'(?P\d{1,8}\.?\d{1,2}?)?m?\s*'\ - r'(?P\d{1,8}\.?\d{1,2}?)?m?\s*(?P\d{1,8}\.?\d{1,2}?)?m?\s*$') + regex = re.compile( + r'(?P\d{1,2}\s+)' + r'(?:(?P\d{1,2}\s+)' + r'(?P\d{1,2}(?:\.\d{1,3})?\s+)?)?' + r'(?P[NS])\s+' + r'(?P\d{1,3}\s+)' + r'(?:(?P\d{1,2}\s+)' + r'(?P\d{1,2}(?:\.\d{1,3})?\s+)?)?' + r'(?P[WE])\s+' + r'(?P-?\d{1,8}(?:\.\d{1,2})?)m?' + r'(?:\s+(?P\d{1,8}(?:\.\d{1,2})?)m?' + r'(?:\s+(?P\d{1,8}(?:\.\d{1,2})?)m?' + r'(?:\s+(?P\d{1,8}(?:\.\d{1,2})?)m?\s*)?)?)?$') m = regex.match(value) -- cgit