#1130: logging crashes when URL contains unicode symbols and user is logged in
(mod_python system)
------------------------+---------------------------------------------------
Reporter: dado1945 | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone: __unclassified__
Component: TurboGears | Version: 1.0.8
Severity: minor | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Comment (by kikidonk):
Ok I understood the problem!
You can reproduce easily using a quickstarted project:
{{{
$ tg-admin quickstart -i -s
$ tg-admin sql create
Modify in controllers.py:15
def index(self): -> def default(self, *args, **kwargs):
$ tg-admin shell
> u = User()
> u.user_name = 'ß'.decode('utf-8')
> u.password = 'foo'
> session.flush()
}}}
Now, go to http://localhost:8080/éé?id=éé
You will see the error related to
http://trac.turbogears.org/turbogears/browser/tags/1.0b1/turbogears/controllers.py#L439
What happens is that it will attempt to generate the log string but the
arguments will be mixed unicode (the user name) and byte-encoded string
(cherrypy.request.requestLine).
The error by itself is simple enough to generate in a python shell:
{{{
print "%s %s" % ('ß'.decode('utf-8'), 'ß')
}}}
If the arguments are mixed unicode and byte-string (outside ascii) python
will try to convert everything to bytestring using ascii (which can't
represent ß)
To wrap up:
* The bug appears only if using an unicode username (outside ascii) and
at the same time having non-ascii chars in the http request
* The bug will make logging crash returning a 500 internal error
* The fix is to either
* encode the username to utf-8 in the log string (and hope the log file
will have consistent encoding, that is, assume the
cherrypy.request.requestLine is utf-8)
* decode the cherrypy.request.requestLine to a unicode string (but
encoding is not known, unless we assume utf-8 and fallback to latin1...)
This is a duplicate of bug #2118 as you mention
--
Ticket URL: <http://trac.turbogears.org/ticket/1130#comment:13>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "TurboGears Tickets" group.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---