]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Properly quote items in sequences 13447/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 3 Nov 2023 09:51:53 +0000 (10:51 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 3 Nov 2023 09:55:59 +0000 (10:55 +0100)
pdns/recursordist/settings/docs-new-preamble-in.rst
pdns/recursordist/settings/generate.py

index e59cb5d1dba817c646b1abf4136edf366eb03f00..05e33f0dd15748dea8a1c1495244db589606961d 100644 (file)
@@ -43,7 +43,7 @@ An example :program:`Recursor` YAML configuration file looks like:
     loglevel: 6
 
 Take care when listing IPv6 addresses, as characters used for these are special to YAML.
-If in doubt, quote any string containing ``:``, ``[`` or ``]`` and use (online) tools to check your YAML syntax.
+If in doubt, quote any string containing ``:``, ``!``, ``[`` or ``]`` and use (online) tools to check your YAML syntax.
 Specify an empty sequence using ``[]``.
 
 The main setting file is called ``recursor.yml`` and will be processed first.
@@ -128,7 +128,7 @@ For example, ``alow-from`` takes a sequence of subnets:
    allow_from:
      - '2001:DB8::/32'
      - 128.66.0.0/16
-     - !128.66.1.2
+     - '!128.66.1.2'
 
 In this case the address ``128.66.1.2`` is excluded from the addresses allowed access.
 
index 5129da3105f99275093a7d096ec7bffcbc2a8796..c06923e6986cef4b8370d81c632f02e4a3c629ec 100644 (file)
@@ -163,9 +163,21 @@ def get_default_newdoc_value(typ, val):
         return '(empty)'
     if typ == LType.String:
         return '``' + val + '``'
-    if val == '':
-        return '``[]``'
-    return '``[' + val + ']``'
+    parts = re.split('[ \t,]+', val)
+    if len(parts) > 0:
+        ret = ''
+        for part in parts:
+            if part == '':
+                continue
+            if ret != '':
+                ret += ', '
+            if ':' in part or '!' in part:
+                ret += "'" + part + "'"
+            else:
+                ret += part
+    else:
+        ret = ''
+    return '``[' + ret + ']``'
 
 def get_rust_type(typ):
     """Determine which Rust type is used for a logical type"""