Browse Source

asn-dns: Add workaround for unicode characters not accepted by KnotDNS

zorun 9 years ago
parent
commit
7098dfed80
1 changed files with 3 additions and 0 deletions
  1. 3 0
      asn-dns.py

+ 3 - 0
asn-dns.py

@@ -45,6 +45,9 @@ def gen_zone(args):
             if "descr" in data:
                 comment += " " + data["descr"][0]
         comment.replace('"', '')
+        # Bind and NSD are quite happy with UTF-8 in TXT records, but
+        # KnotDNS isn't (at least Knot 1.4.7).  This is a hack to work around this.
+        comment = comment.encode('ascii', errors='xmlcharrefreplace').decode()
         out.write('{} TXT "{} | DN42 | dn42 |  | {}"\n'.format(asn, asn[2:], comment))
 
 def cleanup(args):