Issue #824 resolved

_cplogging.LogManager.access method not handling unicode in login names properly

created an issue

The tmpl being written to the access log is not handling unicode strings in {{{ getattr(request, "login", None) or "-" }}}

The code should be: {{{

    tmpl = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"'

    u = getattr(request, "login", None) or "-"
    u = u.encode("utf-8") if isinstance(u, unicode) else u

    s = tmpl % {'h': or remote.ip,
                'l': '-',
                'u': u,
                't': self.time(),
                'r': request.request_line,
                's': response.status.split(" ", 1)[0],
                'b': outheaders.get('Content-Length', '') or "-",
                'f': inheaders.get('referer', ''),
                'a': inheaders.get('user-agent', ''),
        self.access_log.log(logging.INFO, s)


OR.... you can do this in a more complete manner by making tmpl unicode and converting everything to unicode and encoding at the end....

Comments (2)

  1. Log in to comment