Description

Werkzeug fails if path to moin server contains non-ascii characters.

Steps to reproduce

  1. Place Moin code in directory with non-ascii chars
  2. Run it
  3. Try to access it

Example

Component selection

Details

2009-12-06 06:48:49,597 INFO MoinMoin.log:126 using logging configuration read from "/data/programs/мойн/wikiserverlogging.conf"
2009-12-06 06:48:53,537 INFO werkzeug:106  * Running on http://localhost:8080/
2009-12-06 06:50:00,454 INFO MoinMoin.config.multiconfig:127 using wiki config: /data/programs/мойн/wikiconfig.py
2009-12-06 06:50:02,824 ERROR MoinMoin.wsgiapp:262 An exception has occurred [http://127.0.0.1:8080/].

traceback:

   1 Traceback (most recent call last):
   2   File "/data/programs/мойн/MoinMoin/wsgiapp.py", line 250, in __call__
   3     context = init(request)
   4   File "/data/programs/мойн/MoinMoin/wsgiapp.py", line 35, in init
   5     context.session = context.cfg.session_service.get_session(context)
   6   File "/data/programs/мойн/MoinMoin/web/session.py", line 92, in get_session
   7     session = store.get(sid)
   8   File "/data/programs/мойн/MoinMoin/support/werkzeug/contrib/sessions.py", line 218, in get
   9     fn = self.get_session_filename(sid)
  10   File "/data/programs/мойн/MoinMoin/support/werkzeug/contrib/sessions.py", line 199, in get_session_filename
  11     return path.join(self.path, self.filename_template % sid)
  12   File "/usr/lib/python2.5/posixpath.py", line 65, in join
  13     path += '/' + b
  14 UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 15: ordinal not in range(128)

2009-12-06 06:50:03,913 INFO MoinMoin.web.serving:41 127.0.0.1 "GET / HTTP/1.1" 500 -
2009-12-06 06:50:03,922 ERROR werkzeug:106 Error on request:

one more traceback:

   1 Traceback (most recent call last):
   2   File "/data/programs/мойн/MoinMoin/support/werkzeug/serving.py", line 151, in run_wsgi
   3     execute(app)
   4   File "/data/programs/мойн/MoinMoin/support/werkzeug/serving.py", line 138, in execute
   5     application_iter = app(environ, start_response)
   6   File "/data/programs/мойн/MoinMoin/support/werkzeug/utils.py", line 248, in __call__
   7     return self.app(environ, start_response)
   8   File "/data/programs/мойн/MoinMoin/wsgiapp.py", line 250, in __call__
   9     context = init(request)
  10   File "/data/programs/мойн/MoinMoin/wsgiapp.py", line 35, in init
  11     context.session = context.cfg.session_service.get_session(context)
  12   File "/data/programs/мойн/MoinMoin/web/session.py", line 92, in get_session
  13     session = store.get(sid)
  14   File "/data/programs/мойн/MoinMoin/support/werkzeug/contrib/sessions.py", line 218, in get
  15     fn = self.get_session_filename(sid)
  16   File "/data/programs/мойн/MoinMoin/support/werkzeug/contrib/sessions.py", line 199, in get_session_filename
  17     return path.join(self.path, self.filename_template % sid)
  18   File "/usr/lib/python2.5/posixpath.py", line 65, in join
  19     path += '/' + b
  20 UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 15: ordinal not in range(128)

MoinMoin Version

1.9.0

OS and Version

Ubuntu Linux 8.04

Python Version

2.5.2

Server Setup

Server Details

Language you are using the wiki in (set in the browser/UserPreferences)

Workaround

   1 --- moin-1.9.0/MoinMoin/support/werkzeug/contrib/sessions.py    2009-12-06 01:42:19.000000000 +0300
   2 +++ мойн/MoinMoin/support/werkzeug/contrib/sessions.py  2009-12-06 07:11:16.000000000 +0300
   3 @@ -52,7 +52,7 @@
   4      :license: BSD, see LICENSE for more details.
   5  """
   6  import re
   7 -import os
   8 +import os, sys
   9  from os import path
  10  from time import time
  11  from random import random
  12 @@ -192,7 +192,7 @@
  13          if path is None:
  14              from tempfile import gettempdir
  15              path = gettempdir()
  16 -        self.path = path
  17 +        self.path = path.decode(sys.getfilesystemencoding())
  18          self.filename_template = filename_template
  19  
  20      def get_session_filename(self, sid):

Discussion

This bug was first found by RenatoSilva.

Note: alternatively to making path unicode, one could also find out what other unicode attrs are used and make them bytestrings. -- ThomasWaldmann 2009-12-06 11:03:35

Plan


CategoryMoinMoinBugFixed

MoinMoin: MoinMoinBugs/WerkzeugErrorWithNonAsciiPath (last edited 2010-01-21 23:23:17 by RenatoSilva)