diff configmix/config.py @ 325:ab33d51f3412

By default quote the "#" character also because it is typically a comment in all the configuration file formats. Test quoting the "#" also
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 06 May 2021 20:55:43 +0200
parents 4aa19e04ff65
children b7abfbfe806d
line wrap: on
line diff
--- a/configmix/config.py	Thu May 06 20:55:19 2021 +0200
+++ b/configmix/config.py	Thu May 06 20:55:43 2021 +0200
@@ -71,6 +71,7 @@
     _ENDTOK_REF = _ENDTOK
     _DOT = u(b'.')
     _QUOTE = u(b'%')
+    _COMMENT = u(b'#')
 
     def getvarl(self, *names, **kwds):
         """Get a variable where the hierarchy is given in `names` as sequence
@@ -374,14 +375,15 @@
 
     @classmethod
     def quote(klass, s):
-        """Quote a key to protect all dangerous chars: ``%``, ``.``, ``:``
-        and ``|``
+        """Quote a key to protect all dangerous chars: ``%``, ``.``, ``:``,
+        ``#`` and ``|``
 
         """
         qc = klass._QUOTE
         s = s.replace(qc, qc + "x25")
         s = s.replace(klass._DOT, qc + "x2e")
         s = s.replace(klass._NS_SEPARATOR, qc + "x3a")
+        s = s.replace(klass._COMMENT, qc + "x23")
         return s.replace(klass._FILTER_SEPARATOR, qc + "x7c")
 
     @classmethod