diff configmix/config.py @ 334:a04cd5dbcd2c

By default quote also the characters "{", "}", "[" and "]" because they are special in YAML
author Franz Glasner <f.glasner@feldmann-mg.com>
date Fri, 07 May 2021 10:35:21 +0200
parents 5ec0ae3bb8db
children 83f76a41cf7c
line wrap: on
line diff
--- a/configmix/config.py	Fri May 07 09:31:22 2021 +0200
+++ b/configmix/config.py	Fri May 07 10:35:21 2021 +0200
@@ -387,7 +387,7 @@
         characters unicode codepoint value.
 
         Handled are the important special chars: ``%``, ``.``, ``:``,
-        ``#``; ``'``, ``"`` and ``|``.
+        ``#``; ``'``, ``"``, ``|``, ``{``, ``}``, ``[`` and ``]``.
 
         See also the :ref:`quoting` section.
 
@@ -399,7 +399,11 @@
         s = s.replace(klass._COMMENT, qc + "x23")
         s = s.replace(klass._FILTER_SEPARATOR, qc + "x7c")
         s = s.replace('"', qc + "x22")
-        return s.replace("'", qc + "x27")
+        s = s.replace("'", qc + "x27")
+        s = s.replace('{', qc + "x7b")
+        s = s.replace('}', qc + "x7d")
+        s = s.replace('[', qc + "x5b")
+        return s.replace(']', qc + "x5d")
 
     @classmethod
     def unquote(klass, s):