summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Kijak <adam.kijak@ovh.pl>2017-08-18 13:23:10 +0200
committerMaciej Jozefczyk <maciej.jozefczyk@corp.ovh.com>2017-08-31 06:35:51 +0000
commitd9ad4bae1e0d6c43a009d393ac94f7ff50116171 (patch)
treef9f973af9fdd383f6eb040d552f01cbd028863a9
parentdb1fac740124ccf92c68c687b4d2f303d595ff29 (diff)
downloadoslo-middleware-d9ad4bae1e0d6c43a009d393ac94f7ff50116171.tar.gz
Invalid parsing of Forwarded header fixed3.30.1
_parse_rfc7239_header() did not parse properly a Forwarded header with additional spaces Closes-Bug: #1711573 Change-Id: Ic8b7f9698d7b3440005b17d249b1c8f0f66dae8a (cherry picked from commit 480d60ac856937e1a48c1ed6df3b7d2e59a974dc)
-rw-r--r--oslo_middleware/http_proxy_to_wsgi.py2
-rw-r--r--oslo_middleware/tests/test_http_proxy_to_wsgi.py12
2 files changed, 13 insertions, 1 deletions
diff --git a/oslo_middleware/http_proxy_to_wsgi.py b/oslo_middleware/http_proxy_to_wsgi.py
index 4d68bcf..701e5c8 100644
--- a/oslo_middleware/http_proxy_to_wsgi.py
+++ b/oslo_middleware/http_proxy_to_wsgi.py
@@ -49,7 +49,7 @@ class HTTPProxyToWSGI(base.ConfigurableMiddleware):
entry = {}
for d in proxy.split(";"):
key, _, value = d.partition("=")
- entry[key.lower()] = value
+ entry[key.lower().strip()] = value.strip()
result.append(entry)
return result
diff --git a/oslo_middleware/tests/test_http_proxy_to_wsgi.py b/oslo_middleware/tests/test_http_proxy_to_wsgi.py
index d114ad7..7fe9a2a 100644
--- a/oslo_middleware/tests/test_http_proxy_to_wsgi.py
+++ b/oslo_middleware/tests/test_http_proxy_to_wsgi.py
@@ -89,6 +89,18 @@ class TestHTTPProxyToWSGI(test_base.BaseTestCase):
response = self.request.get_response(self.middleware)
self.assertEqual(b"https://localhost:80/", response.body)
+ def test__parse_rfc7239_header(self):
+ expected_result = [{'for': 'foobar', 'proto': 'https'},
+ {'for': 'foobaz', 'proto': 'http'}]
+
+ result = self.middleware._parse_rfc7239_header(
+ "for=foobar;proto=https, for=foobaz;proto=http")
+ self.assertEqual(expected_result, result)
+
+ result = self.middleware._parse_rfc7239_header(
+ "for=foobar; proto=https, for=foobaz; proto=http")
+ self.assertEqual(expected_result, result)
+
def test_rfc7239_proto_host(self):
self.request.headers['Forwarded'] = (
"for=foobar;proto=https;host=example.com, for=foobaz;proto=http")