#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:  1.0b3    
Component:  TurboGears  |      Version:  1.0b1    
 Severity:  normal      |   Resolution:           
 Keywords:              |  
------------------------+---------------------------------------------------
Changes (by jorge.vargas):

  * severity:  critical => normal
  * milestone:  => 1.0b3

Old description:

> It is quite hard to reproduce this bug because it requires TurboGears
> running behind apache using mod_python.
> I think similar configuration was used:
> http://trac.turbogears.org/turbogears/wiki/ModPythonIntegration09
>
> Next requirement is unicode characters in URL and user must be logged in
> (I am using standart TG identity mechanism).
>
> This produce following traceback (and system does not work as intended):
>
> 2006-09-28 12:30:53,818 cherrypy.msg INFO : Page handler: 'ordinal not in
> range(128)'
> Traceback (most recent call last):
>   File "/usr/lib/python2.4/site-
> packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cpwsgi.py", line 75, in
> wsgiApp
>     environ['wsgi.input'])
>   File "/usr/lib/python2.4/site-
> packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cphttptools.py", line 78, in
> run
>     _cputil.get_special_attribute("_cp_log_access", "_cpLogAccess")()
>   File "/usr/lib/python2.4/site-packages/TurboGears-1.0b1-
> py2.4.egg/turbogears/controllers.py", line 450, in _cp_log_access
>     '') or "-",
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 28:
> ordinal not in range(128)
>

> The reason can be illustrated with following example:
>
> >>> a
> 'dalius'
> >>> b
> '\xc5\xbev\xc4\x97ris'
> >>> '%s %s' % (a, b)
> 'dalius \xc5\xbev\xc4\x97ris'
> >>> a = u'dalius'
> >>> '%s %s' % (a, b)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 0:
> ordinal not in range(128)
> >>>
>

> If we check /usr/lib/python2.4/site-packages/TurboGears-1.0b1-
> py2.4.egg/turbogears/controllers.py line 450 we will find that username
> is unicode and url is utf-8 string. I think following check would help:
>
> if isinstance(username, unicode):
>     username = username.encode('utf-8')

New description:

 It is quite hard to reproduce this bug because it requires TurboGears
 running behind apache using mod_python.
 I think similar configuration was used:
 http://trac.turbogears.org/turbogears/wiki/ModPythonIntegration09

 Next requirement is unicode characters in URL and user must be logged in
 (I am using standart TG identity mechanism).

 This produce following traceback (and system does not work as intended):
 {{{
 2006-09-28 12:30:53,818 cherrypy.msg INFO : Page handler: 'ordinal not in
 range(128)'
 Traceback (most recent call last):
   File "/usr/lib/python2.4/site-
 packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cpwsgi.py", line 75, in
 wsgiApp
     environ['wsgi.input'])
   File "/usr/lib/python2.4/site-
 packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cphttptools.py", line 78, in
 run
     _cputil.get_special_attribute("_cp_log_access", "_cpLogAccess")()
   File "/usr/lib/python2.4/site-packages/TurboGears-1.0b1-
 py2.4.egg/turbogears/controllers.py", line 450, in _cp_log_access
     '') or "-",
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 28:
 ordinal not in range(128)

 }}}
 The reason can be illustrated with following example:
 {{{
 >>> a
 'dalius'
 >>> b
 '\xc5\xbev\xc4\x97ris'
 >>> '%s %s' % (a, b)
 'dalius \xc5\xbev\xc4\x97ris'
 >>> a = u'dalius'
 >>> '%s %s' % (a, b)
 Traceback (most recent call last):
   File "<stdin>", line 1, in ?
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 0:
 ordinal not in range(128)
 >>>

 }}}

 If we check /usr/lib/python2.4/site-packages/TurboGears-1.0b1-
 py2.4.egg/turbogears/controllers.py line 450 we will find that username is
 unicode and url is utf-8 string. I think following check would help:
 {{{
 if isinstance(username, unicode):
     username = username.encode('utf-8')
 }}}

Comment:

 -fixed some formatting... embrace wiki!

 -I do not undestand why it requires mod_python if you can reproduce on the
 console.

 are you refering to
 
http://trac.turbogears.org/turbogears/browser/tags/1.0b1/turbogears/controllers.py#L450,
 there is nothing there about user just a flew lines up.

 on the other hand I believe URLs must be ascii at least according to the
 specs.

 last but not least I believe your problem is with the usernames not being
 unicode and not the URLs (unless your passing in the users as URL) as in
 "per user pages httP//www.foo.com/elpargo" where elpargo is the user.


 because the value your pulling is from "username =
 cherrypy.request.user_name" in which case the fix should be in the code
 that puts that value into de request, I think.

-- 
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/1130>
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.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---

Reply via email to