Merge *base_prefix config keys into base_prefix (fixes #996)

This commit is contained in:
Guillaume Ayoub
2013-04-30 14:02:17 +02:00
parent eaa969a05c
commit bf8e874e4d
6 changed files with 39 additions and 40 deletions

View File

@@ -246,9 +246,17 @@ class Application(object):
headers = pprint.pformat(self.headers_log(environ))
log.LOGGER.debug("Request headers:\n%s" % headers)
# Sanitize request URI
environ["PATH_INFO"] = self.sanitize_uri(environ["PATH_INFO"])
log.LOGGER.debug("Sanitized path: %s", environ["PATH_INFO"])
base_prefix = config.get("server", "base_prefix")
if environ["PATH_INFO"].startswith(base_prefix):
# Sanitize request URI
environ["PATH_INFO"] = self.sanitize_uri(
"/%s" % environ["PATH_INFO"][len(base_prefix):])
log.LOGGER.debug("Sanitized path: %s", environ["PATH_INFO"])
else:
# Request path not starting with base_prefix, not allowed
log.LOGGER.debug(
"Path not starting with prefix: %s", environ["PATH_INFO"])
environ["PATH_INFO"] = None
# Get content
content_length = int(environ.get("CONTENT_LENGTH") or 0)