Mercurial > hgrepos > Python > libs > ConfigMix
changeset 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 | 97d47c5150d6 |
| files | configmix/config.py tests/test.py |
| diffstat | 2 files changed, 8 insertions(+), 3 deletions(-) [+] |
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):
--- a/tests/test.py Fri May 07 09:31:22 2021 +0200 +++ b/tests/test.py Fri May 07 10:35:21 2021 +0200 @@ -782,7 +782,8 @@ self._cfg.getvar_s("events.qc-2021%x2e1-5G-summit.xref.%x23")) def test_quoting_and_unquoting_are_inverse(self): - for c in """abc09'"#:|%./""": + for c in """abc09'"#:|%.{}[]/""": + print c self.assertEqual(c, self._cfg.unquote(self._cfg.quote(c))) def test_namespace_quoting(self):
