Parcourir la source

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

zorun il y a 9 ans
Parent
commit
7098dfed80
1 fichiers modifiés avec 3 ajouts et 0 suppressions
  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):