Skip to content

Commit

Permalink
deal with unicode names slightly better
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Hammel committed Jun 2, 2011
1 parent 2187d09 commit 08299bc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions toolbox/handlers.py
Expand Up @@ -7,14 +7,19 @@
import os
from datetime import datetime
from pkg_resources import resource_filename
from urllib import quote
from urllib import quote as _quote
from urlparse import urlparse
from util import strsplit
from util import JSONEncoder
from webob import Response, exc
from tempita import HTMLTemplate
from time import time

def quote(s, safe='/'):
if isinstance(s, unicode):
s = s.encode('utf-8', 'ignore') # hope we're using utf-8!
return _quote(s, safe)

try:
import json
except ImportError:
Expand Down Expand Up @@ -269,7 +274,13 @@ def match(cls, app, request):
return None

# get the project if it exists
project = app.model.project(request.environ['path'][0])
projectname = request.environ['path'][0]
try:
# if its utf-8, we should try to keep it utf-8
projectname = projectname.decode('utf-8')
except UnicodeDecodeError:
pass
project = app.model.project(projectname)
if not project:
return None

Expand Down

0 comments on commit 08299bc

Please sign in to comment.