diff --git a/src/netbox_plugin_bind_provisioner/__init__.py b/src/netbox_plugin_bind_provisioner/__init__.py index 036c8f2..c1d2f99 100644 --- a/src/netbox_plugin_bind_provisioner/__init__.py +++ b/src/netbox_plugin_bind_provisioner/__init__.py @@ -5,7 +5,7 @@ from django.utils.translation import gettext_lazy as _ from django.dispatch import receiver from django.conf import settings -__version__ = "1.0.2" +__version__ = "1.0.3" logger = logging.getLogger(__name__) diff --git a/src/netbox_plugin_bind_provisioner/management/commands/bind-transfer-endpoint.py b/src/netbox_plugin_bind_provisioner/management/commands/bind-transfer-endpoint.py index 0cb6cab..758beaa 100644 --- a/src/netbox_plugin_bind_provisioner/management/commands/bind-transfer-endpoint.py +++ b/src/netbox_plugin_bind_provisioner/management/commands/bind-transfer-endpoint.py @@ -251,16 +251,17 @@ class DNSBaseRequestHandler(socketserver.BaseRequestHandler): # from cutting it up: value = record.value if rdtype == dns.rdatatype.TXT: - if not value.startswith('"') and not value.endswith('"'): - value = value.replace('"', '\\"') - if len(value) <= 255: - value = f'"{value}"' - else: - # This is a bug fix for netbox. If netbox allowed for - # an unquoted value to be larger then 255 characters, - # it misunderstood everything behind a ; as a comment. - chunks = ['"{}"'.format(value[i:i+255]) for i in range(0, len(value), 255)] - value = " ".join(chunks) + if value.startswith('"') and value.endswith('"'): + value = value[1:-1].replace('" "', '').replace('"', '\"') + + if len(value) > 255: + # This is a bug fix for netbox. If netbox allowed for + # an unquoted value to be larger then 255 characters, + # it misunderstood everything behind a ; as a comment. + chunks = ['"{}"'.format(value[i:i+255]) for i in range(0, len(value), 255)] + value = " ".join(chunks) + else: + value = f'"{value}"' rdata = dns.rdata.from_text( dns.rdataclass.IN,