PathagarBooks / pathagar

Pathagar is a simple bookserver serving OPDS feeds
GNU General Public License v2.0
101 stars 26 forks source link

Covers not displayed when path contains UTF-8 accentuated characters #16

Open SR-G opened 11 years ago

SR-G commented 11 years ago

Picture is not displayed ("broken image"). If i copy/paste the direct link address (for example : http://192.168.1.4:8000/covers/Hom%C3%A8re-Liliade_et_lodyss%C3%A9e_illustr%C3%A9s.jpg )

Here is the error i get : 'ascii' codec can't encode character u'\xe8' in position 63: ordinal not in range(128)

Seems to be on the django-side.

Environment:

Request Method: GET
Request URL: http://192.168.1.4:8000/covers/Hom%C3%A8re-Liliade_et_lodyss%C3%A9e_illustr%C3%A9s.jpg

Django Version: 1.3.1
Python Version: 2.7.3
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'tagging',
 'pathagar.books']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')

Traceback:
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/dist-packages/django/views/static.py" in serve
  46.     if os.path.isdir(fullpath):
File "/usr/lib/python2.7/genericpath.py" in isdir
  41.         st = os.stat(s)

Exception Type: UnicodeEncodeError at /covers/Homère-Liliade_et_lodyssée_illustrés.jpg
Exception Value: 'ascii' codec can't encode character u'\xe8' in position 63: ordinal not in range(128)

Correct filename on filesystem is : Homère-Liliade_et_lodyssée_illustrés.jpg

SR-G commented 11 years ago

Ok, i think you can forget about that one : my /etc/init.d/pathagar script hadn't those two lines :

export LANG='fr_FR.UTF-8'
export LC_ALL='fr_FR.UTF-8'

Once added, images with accentuated characters are now correctly displayed.

lionaneesh commented 11 years ago

This should be closed. According to the bug reporter: exporting correct LANG's in the /etc/init.d/pathagar fixes the issue.

sethwoodworth commented 11 years ago

This should be documented then closed