Issue #1303 new

error_page.404 utf-8 handling error

Anonymous created an issue

Hi, i have russian chars encoded with utf-8 in 404.html

When referring to a nonexistent page get an "500 Internal Server Error"

The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
  File "C:\Work\Internet\library\python\lib\site-packages\cherrypy\", line 664, in respond
  File "C:\Work\Internet\library\python\lib\site-packages\cherrypy\", line 376, in set_response
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 149: ordinal not in range(128)
Powered by CherryPy 3.2.5


        'global': {
            'error_page.404': r'%s/public/internet/errors/404.html' % WORKING_DIRECTORY

Comments (7)

  1. Sviatoslav Sydorenko


    I found a workaround for this (I may prepare a pull-request once tested under python2). All works if you replace encoding in wsgiserver/ to utf-8 as follows:

    sed -i 's/ISO-8859-1/UTF-8/g' wsgiserver/

    BTW, why don't you use default urllib.parse.unquote here?

    P.S. I'm running python 3.3 and issue exists in 3.2.4 and 3.2.5. I've mentioned it while using staticdir and requesting url like http://hostname/uploads/gallery/photo/clients/%D1%81%D0%B2%D0%B5%D1%82%D0%BB%D0%BE%D1%84%D0%BEp.png, the filename should be decoded to светлофоp, but in fact it isn't.

  2. Log in to comment