Browse Source

apply support for YamlProvider.escaped_semicolons=false

pull/1253/head
Ross McFarland 5 months ago
parent
commit
d2da48c063
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
2 changed files with 25 additions and 2 deletions
  1. +5
    -0
      octodns/provider/yaml.py
  2. +20
    -2
      tests/test_octodns_provider_yaml.py

+ 5
- 0
octodns/provider/yaml.py View File

@ -420,6 +420,11 @@ class YamlProvider(BaseProvider):
if record.ttl == self.default_ttl:
# ttl is the default, we don't need to store it
del d['ttl']
if not self.escaped_semicolons and record._type in ('SPF', 'TXT'):
if 'value' in d:
d['value'] = d['value'].replace('\\;', ';')
if 'values' in d:
d['values'] = [v.replace('\\;', ';') for v in d['values']]
# we want to output the utf-8 version of the name
data[record.decoded_name].append(d)


+ 20
- 2
tests/test_octodns_provider_yaml.py View File

@ -494,9 +494,9 @@ xn--dj-kia8a:
two.values,
)
zone = Zone('escaped.semis.', [])
escaped = Zone('escaped.semis.', [])
with self.assertRaises(ValidationError) as ctx:
source.populate(zone)
source.populate(escaped)
self.assertEqual(
[
'double escaped ; in "This has a semi-colon\\\\; that is escaped."'
@ -504,6 +504,24 @@ xn--dj-kia8a:
ctx.exception.reasons,
)
with TemporaryDirectory() as td:
# Add some subdirs to make sure that it can create them
target = YamlProvider(
'target', td.dirname, escaped_semicolons=False
)
yaml_file = join(td.dirname, 'unescaped.semis.yaml')
plan = target.plan(zone)
target.apply(plan)
with open(yaml_file) as fh:
content = fh.read()
self.assertTrue('value: This has a semi-colon; that' in content)
self.assertTrue(
"- This has a semi-colon too; that isn't escaped." in content
)
self.assertTrue('- ;' in content)
class TestSplitYamlProvider(TestCase):
def test_list_all_yaml_files(self):


Loading…
Cancel
Save