summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2011-07-24 22:07:17 +0200
committerHelmut Grohne <helmut@subdivi.de>2011-07-24 22:07:17 +0200
commit0c93b64584c7067d7a5f6876ded2a59ad021d3bc (patch)
tree54cb1ed112868fdff8565a73b6e35b1f3cc78a61
parent64bd60ab5c1ca373917b65c28a6234f9f19d26a1 (diff)
downloadwsgitools-0c93b64584c7067d7a5f6876ded2a59ad021d3bc.tar.gz
filters.escape_string: do not consider \ printable
Otherwise escape_string is not reversible.
-rw-r--r--wsgitools/filters.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/wsgitools/filters.py b/wsgitools/filters.py
index 7062357..1c3fadc 100644
--- a/wsgitools/filters.py
+++ b/wsgitools/filters.py
@@ -203,9 +203,10 @@ class WSGIFilterMiddleware:
# Using map and lambda here since pylint cannot handle list comprehension in
# default arguments. Also note that neither ' nor " are considered printable.
+# For escape_string to be reversible \ is also not considered printable.
def escape_string(string, replacer=list(map(
lambda i: chr(i) if chr(i).isalnum() or
- chr(i) in '!#$%&()*+,-./:;<=>?@[\\]^_`{|}~ ' else
+ chr(i) in '!#$%&()*+,-./:;<=>?@[]^_`{|}~ ' else
r"\x%2.2x" % i,
range(256)))):
"""Encodes non-printable characters in a string using \\xXX escapes.