diff --git a/CHANGELOG.md b/CHANGELOG.md index afded1f..09aeeae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v1.?.? - 2024-??-?? - ??? + +* Fix CAA rdata parsing to allow values with tags + ## v1.7.0 - 2024-04-29 - All the knobs and dials * Support for specifying per-zone change thresholds, to allow for zones diff --git a/octodns/record/caa.py b/octodns/record/caa.py index f512e9a..a9d048e 100644 --- a/octodns/record/caa.py +++ b/octodns/record/caa.py @@ -13,7 +13,8 @@ class CaaValue(EqualityTupleMixin, dict): @classmethod def parse_rdata_text(cls, value): try: - flags, tag, value = value.split(' ') + # value may contain whitepsace + flags, tag, value = value.split(' ', 2) except ValueError: raise RrParseError() try: diff --git a/tests/test_octodns_record_caa.py b/tests/test_octodns_record_caa.py index d7c020b..8caecb9 100644 --- a/tests/test_octodns_record_caa.py +++ b/tests/test_octodns_record_caa.py @@ -41,7 +41,7 @@ class TestRecordCaa(TestCase): self.assertEqual(a_data, a.data) b_value = CaaValue( - {'tag': 'iodef', 'value': 'http://iodef.example.com/'} + {'tag': 'iodef', 'value': 'http://iodef.example.com/; key=value'} ) b_data = {'ttl': 30, 'value': b_value} b = CaaRecord(self.zone, 'b', b_data) @@ -89,10 +89,6 @@ class TestRecordCaa(TestCase): with self.assertRaises(RrParseError): CaaValue.parse_rdata_text('0 tag') - # 4th word won't parse - with self.assertRaises(RrParseError): - CaaValue.parse_rdata_text('1 tag value another') - # flags not an int, will parse self.assertEqual( {'flags': 'one', 'tag': 'tag', 'value': 'value'}, @@ -105,12 +101,24 @@ class TestRecordCaa(TestCase): CaaValue.parse_rdata_text('0 tag 99148c81'), ) + # 4th word will parse, and be part of the value + self.assertEqual( + {'flags': 1, 'tag': 'tag', 'value': 'value another'}, + CaaValue.parse_rdata_text('1 tag value another'), + ) + # quoted self.assertEqual( {'flags': 0, 'tag': 'tag', 'value': '99148c81'}, CaaValue.parse_rdata_text('0 "tag" "99148c81"'), ) + # quoted w/4th word + self.assertEqual( + {'flags': 0, 'tag': 'tag', 'value': '99148c81 key=val'}, + CaaValue.parse_rdata_text('0 "tag" "99148c81 key=val"'), + ) + zone = Zone('unit.tests.', []) a = CaaRecord( zone,