Commit 26115ba5 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Escape logged HTTP data before token replacement

Problem: when LOG_DATA is on and LOG_TOKEN is off, kamaki logs HTTP
data, replaces the token (if it is included in the data) and then
escapes them to prepare for safe logging. If the data is non-ascii,
replacing raises a unicode error.

Solution: escape data before replacing the token.
parent 2a2faa29
......@@ -293,9 +293,10 @@ class ResponseManager(Logged):
len(self._content) if self._content else 0, plog))
if self.LOG_DATA and self._content:
data = '%s%s' % (self._content, plog)
data = utils.escape_ctrl_chars(data)
if self._token:
data = data.replace(self._token, '...')
except Exception as err:
if isinstance(err, HTTPException):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment