Commit 144c48ba authored by Lukáš Lalinský's avatar Lukáš Lalinský

Accept API URLs with double slashes

parent 0b9f8ce3
Pipeline #20401 failed with stages
in 1 minute and 26 seconds
......@@ -96,6 +96,13 @@ class GzipRequestMiddleware(object):
return, start_response)
def replace_double_slashes(app):
def wrapped_app(environ, start_response):
environ['PATH_INFO'] = environ['PATH_INFO'].replace('//', '/')
return app(environ, start_response)
return wrapped_app
def make_application(config_path):
"""Construct a WSGI application for the AcoustID server
......@@ -106,4 +113,5 @@ def make_application(config_path):
app = GzipRequestMiddleware(server)
app = ProxyFix(app)
app = SentryWsgiMiddleware(app)
app = replace_double_slashes(app)
return server, app
......@@ -3,8 +3,9 @@
from import assert_equals
import gzip
import wsgiref.util
from cStringIO import StringIO
from acoustid.server import GzipRequestMiddleware
from acoustid.server import GzipRequestMiddleware, replace_double_slashes
def test_gzip_request_middleware():
......@@ -20,5 +21,16 @@ def test_gzip_request_middleware():
'CONTENT_LENGTH': len(data),
'wsgi.input': StringIO(data),
mw = GzipRequestMiddleware(app)
mw(environ, None)
def test_replace_double_slashes():
def app(environ, start_response):
assert_equals('/v2/user/lookup', environ['PATH_INFO'])
gzcontent = StringIO()
environ = {'PATH_INFO': '/v2//user//lookup'}
mw = replace_double_slashes(app)
mw(environ, None)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment