summaryrefslogtreecommitdiff
path: root/swift/common/middleware/proxy_logging.py
diff options
context:
space:
mode:
authorgholt <z-launchpad@brim.net>2013-04-20 04:16:57 +0000
committergholt <z-launchpad@brim.net>2013-04-20 04:26:21 +0000
commitcd8af3f8f1a3762eb1591cd4b312b15d01675b74 (patch)
treedb33960cf90e34691b156497c0bc58de5f328286 /swift/common/middleware/proxy_logging.py
parentf63dc07b9da568c4bbe206278334fa1fb8a13be9 (diff)
downloadswift-cd8af3f8f1a3762eb1591cd4b312b15d01675b74.tar.gz
Made colons quote-safe in logs; mainly for ipv6
Previous logging made a mess of ipv6 addresses. This just makes the colon quote-safe so it passes through unscathed. The logs will still be backward compatible because unquote don't care: $ python >>> from urllib import quote, unquote >>> quote('2001:db8:85a3:8d3:1319:8a2e:370:7348') '2001%3Adb8%3A85a3%3A8d3%3A1319%3A8a2e%3A370%3A7348' >>> unquote(quote('2001:db8:85a3:8d3:1319:8a2e:370:7348')) '2001:db8:85a3:8d3:1319:8a2e:370:7348' >>> quote('2001:db8:85a3:8d3:1319:8a2e:370:7348', '/:') '2001:db8:85a3:8d3:1319:8a2e:370:7348' >>> unquote(quote('2001:db8:85a3:8d3:1319:8a2e:370:7348', '/:')) '2001:db8:85a3:8d3:1319:8a2e:370:7348' Change-Id: Ia13a9bc8a320cde5c56034a7f0b645913428bf21
Diffstat (limited to 'swift/common/middleware/proxy_logging.py')
-rw-r--r--swift/common/middleware/proxy_logging.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/swift/common/middleware/proxy_logging.py b/swift/common/middleware/proxy_logging.py
index 97950a7c9..273c31064 100644
--- a/swift/common/middleware/proxy_logging.py
+++ b/swift/common/middleware/proxy_logging.py
@@ -66,6 +66,8 @@ from swift.common.utils import (get_logger, get_remote_client,
get_valid_utf8_str, config_true_value,
InputProxy)
+QUOTE_SAFE = '/:'
+
class ProxyLoggingMiddleware(object):
"""
@@ -122,7 +124,7 @@ class ProxyLoggingMiddleware(object):
if self.req_already_logged(req):
return
req_path = get_valid_utf8_str(req.path)
- the_request = quote(unquote(req_path))
+ the_request = quote(unquote(req_path), QUOTE_SAFE)
if req.query_string:
the_request = the_request + '?' + req.query_string
logged_headers = None
@@ -131,7 +133,7 @@ class ProxyLoggingMiddleware(object):
for k, v in req.headers.items())
method = self.method_from_req(req)
self.access_logger.info(' '.join(
- quote(str(x) if x else '-')
+ quote(str(x) if x else '-', QUOTE_SAFE)
for x in (
get_remote_client(req),
req.remote_addr,