# HG changeset patch # User Franz Glasner # Date 1639743139 -3600 # Node ID e3990ec55f2a1d43cdeab8b0119e5cf5093c5d62 # Parent 3cfc808e613bc9f7608b1cd674dcb6b023f8b60b Use a quick-check for .quote() if no quoting is needed diff -r 3cfc808e613b -r e3990ec55f2a configmix/config.py --- a/configmix/config.py Fri Dec 17 12:49:07 2021 +0100 +++ b/configmix/config.py Fri Dec 17 13:12:19 2021 +0100 @@ -237,6 +237,13 @@ _QUOTE_u = u(b'u') _QUOTE_U = u(b'U') _COMMENT = u(b'#') + _QUOTE_SAFE = u(b'abcdefghijklmnopqrstuvwxyz' + b'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + b'0123456789' + b'-_@!§$&/()=?*+~;,<>´`^') + """Mostly used configuration key characters that do not need any quoting + + """ is_jail = False """Flag to show that this is not a jail for another configuration""" @@ -700,6 +707,10 @@ See also the :ref:`quoting` section. """ + # Quick check whether all of the chars is in _QUOTE_SAFE + if not s.rstrip(klass._QUOTE_SAFE): + return s + # Slow path qc = klass._QUOTE s = s.replace(qc, qc + "x25") s = s.replace(klass._DOT, qc + "x2e")