Skip to content

Commit

Permalink
urlquote url when the server is lighttpd. (Bug#339858)
Browse files Browse the repository at this point in the history
Apache and CherryPy webservers unquote the url but lighttpd doesn't.
unquote explicitly for lighttpd to make ctx.path uniform across all servers.
  • Loading branch information
anandology committed Mar 9, 2009
1 parent 0f82456 commit ab3435f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions web/application.py
Expand Up @@ -355,6 +355,9 @@ def load(self, env):
# http://trac.lighttpd.net/trac/ticket/406 requires:
if env.get('SERVER_SOFTWARE', '').startswith('lighttpd/'):
ctx.path = lstrips(env.get('REQUEST_URI').split('?')[0], ctx.homepath)
# Apache and CherryPy webservers unquote the url but lighttpd doesn't.
# unquote explicitly for lighttpd to make ctx.path uniform across all servers.
ctx.path = urllib.unquote(ctx.path)

if env.get('QUERY_STRING'):
ctx.query = '?' + env.get('QUERY_STRING', '')
Expand Down Expand Up @@ -425,7 +428,7 @@ def _match(self, mapping, value):
result = utils.re_compile('^' + pat + '$').match(value)

if result: # it's a match
return what, [x and urllib.unquote(x) for x in result.groups()]
return what, [x for x in result.groups()]
return None, None

def _delegate_sub_application(self, dir, app):
Expand Down Expand Up @@ -537,7 +540,7 @@ def _match(self, mapping, value):
result = utils.re_compile('^' + pat + '$').match(value)

if result: # it's a match
return what, [x and urllib.unquote(x) for x in result.groups()]
return what, [x for x in result.groups()]
return None, None

def loadhook(h):
Expand Down

0 comments on commit ab3435f

Please sign in to comment.