I’m trying to get a handler mapping working with Google App Engine.
The regex is like this:
('/api/1/apps/([-0-9a-zA-Z]+)/values/(.+)', ApiValueHandler)
When the URL looks like /api/1/apps/50b96eb0/values/New%20note%2Fhello the value that gets passed to my handler is New%20note/hello. As you can see it’s unescaping the slash, but not the space.
Is there a setting I’m missing somewhere, or do I need to do some unescaping myself? If there are some values it will never unescape is there a list of these somewhere?
Updated:
Here’s a test app that shows this behaviour when run on the dev server on Windows 7 with Python 2.5.
main.py
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
class MainHandler(webapp.RequestHandler):
def get(self, blah):
self.response.out.write(blah)
app = webapp.WSGIApplication([('/(.*)', MainHandler)], debug=True)
util.run_wsgi_app(app)
app.yaml
application: engineapp
version: 1
runtime: python
api_version: 1
handlers:
- url: .*
script: main.py
Not escaped characters are defined by
quote: letters, digits,_.-and the default safe character/.http://docs.python.org/library/urllib.html#urllib.quote
Just use
unquoteon the matched string.http://docs.python.org/library/urllib.html#urllib.unquote