# HG changeset patch # User Franz Glasner # Date 1623355329 -7200 # Node ID d7daec11938392699992091f1ab998bcd6b5aeb1 # Parent 1c207cad532aacc7efa5ff32649282e6399c11e9 New filter function "urlquote_plus" which quotes a space into a '+' character diff -r 1c207cad532a -r d7daec119383 CHANGES.txt --- a/CHANGES.txt Mon May 10 09:28:14 2021 +0200 +++ b/CHANGES.txt Thu Jun 10 22:02:09 2021 +0200 @@ -12,6 +12,13 @@ Pre-1.0 Series -------------- +n/a (not yet) +~~~~~~~~~~~~~ + +- **[feature]** + New filter function :py:func:`urlquote_plus` + + 0.14 (2021-05-10) ~~~~~~~~~~~~~~~~~ diff -r 1c207cad532a -r d7daec119383 configmix/variables.py --- a/configmix/variables.py Mon May 10 09:28:14 2021 +0200 +++ b/configmix/variables.py Thu Jun 10 22:02:09 2021 +0200 @@ -163,25 +163,45 @@ @filter("urlquote") def urlquote(config, v): - """Filter function to replace all special characters in string using - the ``%xx`` escape + """Filter function to replace all special characters in string `v` + using the ``%xx`` escape """ from urllib import quote return quote(v.encode("utf-8"), safe=b"").decode("utf-8") + + @filter("urlquote_plus") + def urlquote_plus(config, v): + """Filter function to replace all special characters (including + spaces) in string `v` using the ``%xx`` escape + + """ + from urllib import quote_plus + return quote_plus(v.encode("utf-8"), safe=b"").decode("utf-8") + else: @filter("urlquote") def urlquote(config, v): - """Filter function to replace all special characters in string using - the ``%xx`` escape + """Filter function to replace all special characters in string `v` + using the ``%xx`` escape """ from urllib.parse import quote return quote(v, safe="") + @filter("urlquote_plus") + def urlquote_plus(config, v): + """Filter function to replace all special characters (including + spaces) in string `v` using the ``%xx`` escape + + """ + from urllib.parse import quote_plus + return quote_plus(v, safe="") + + @filter("saslprep") def saslprep(config, v): """Filter function to perform a `SASLprep` according to :rfc:`4013` on diff -r 1c207cad532a -r d7daec119383 docs/introduction.rst --- a/docs/introduction.rst Mon May 10 09:28:14 2021 +0200 +++ b/docs/introduction.rst Thu Jun 10 22:02:09 2021 +0200 @@ -403,6 +403,8 @@ ``urlquote`` + ``urlquote_plus`` + ``saslprep`` ``normpath``