From 6885e19fd7d5ed63be28fd3b490ea70d0b5ab758 Mon Sep 17 00:00:00 2001 From: James Murphy Date: Thu, 18 Feb 2016 12:43:43 +1100 Subject: [PATCH] Fixed issue where some headers would come through with only 1 character --- daphne/ws_protocol.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/daphne/ws_protocol.py b/daphne/ws_protocol.py index 8abdf44..0d77e6a 100755 --- a/daphne/ws_protocol.py +++ b/daphne/ws_protocol.py @@ -4,6 +4,7 @@ import logging import time import traceback from six.moves.urllib.parse import urlencode +from six import string_types from autobahn.twisted.websocket import WebSocketServerProtocol, WebSocketServerFactory @@ -29,7 +30,10 @@ class WebSocketProtocol(WebSocketServerProtocol): # Prevent CVE-2015-0219 if "_" in name: continue - clean_headers[name.lower()] = value[0].encode("latin1") + if isinstance(value, string_types): + clean_headers[name.lower()] = value.encode("latin1") + else: + clean_headers[name.lower()] = value[0].encode("latin1") # Reconstruct query string # TODO: get autobahn to provide it raw query_string = urlencode(request.params).encode("ascii")